The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Improve studio Dockerfile
Ruggero Tomasellie5c4fd5a0753
diff --git a/studio/Dockerfile b/studio/Dockerfileindex a55ed33b9ea..e9614bb583f 100644--- a/studio/Dockerfile+++ b/studio/Dockerfile@@ -1,9 +1,11 @@+# To be run in the root of the turbo monorepo+# NOTE: It's highly raccomended to use the new builder, Buildkit. https://docs.docker.com/build/buildkit/## USAGE:-# Build: docker build --target production -t supabase/studio:latest .+# Build: docker buildx build --target production -t supabase/studio:latest .# Run: docker run -p 3000:3000 supabase/studio# Deploy: docker push supabase/studio:latest# Clean build:-# docker build --target production --no-cache -t supabase/studio:latest .+# docker buildx build --target production --no-cache -t supabase/studio:latest .# docker builder pruneFROM node:16-slim as base@@ -11,36 +13,52 @@ RUN apt-get update && apt-get install -y --no-install-recommends \python3 \build-essential \&& rm -rf /var/lib/apt/lists/*+RUN npm i -g turbo-FROM base as builder-WORKDIR /usr/src/app-COPY package*.json ./-COPY turbo.json .-COPY packages packages-COPY studio studio-# the following command is still unsupported for npm // https://github.com/vercel/turborepo/issues/1830-# RUN npm i -g turbo-# RUN turbo prune --scope=studio --docker-# RUN npm clean-install && npm cache clean --force+# Calculate if dependencies are outdated+FROM base as turbo+WORKDIR /app+COPY . .+# Prune unneeded dependencies with turbo (from apps/ for example)+RUN turbo prune --scope=studio --docker++# Install dev dependencies (only if needed)+FROM base as deps+WORKDIR /app+COPY --from=turbo /app/out/json/ .+COPY --from=turbo /app/out/package-lock.json ./+RUN npm clean-install && npm cache clean --force++FROM deps as deps-prod+RUN npm prune --production+# Remove packages dependencies (not needed in production)+RUN rm -rf /app/packages++# builder contains dependencies and source code not compiled+FROM deps as builder+WORKDIR /app+COPY --from=turbo /app/out/full ./ENTRYPOINT ["docker-entrypoint.sh"]FROM builder as dev-COPY --from=builder /usr/src/app ./-RUN npm clean-install && npm cache clean --forceEXPOSE 8082CMD ["npx", "turbo", "run", "dev", "--filter=studio"]+# Compile NextJSFROM builder as productionprepWORKDIR /app-COPY --from=builder /usr/src/app ./-RUN npm clean-install \- && npm cache clean --force \- && npx turbo run build --scope=studio --include-dependencies --no-deps \- && rm -rf ./studio/.next/cache/webpack \- && npm prune --production+RUN npx turbo run build --scope=studio --include-dependencies --no-deps \+ && rm -rf ./studio/.next/cache/webpack+# Copy only compiled code and dependenciesFROM node:16-slim as production-COPY --from=productionprep /app /app+# Copy package(s).json and package-lock.json+COPY --from=turbo /app/out/json /app+# Copy all dependencies for production+COPY --from=deps-prod /app /app+# Copy necessary files+COPY --from=turbo /app/out/full/studio /app/studio+COPY --from=productionprep /app/studio/.next /app/studio/.nextWORKDIR /app/studioEXPOSE 3000CMD ["npm", "run", "start"]