Skip to content

Instantly share code, notes, and snippets.

@hypeJunction
Last active June 15, 2022 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hypeJunction/ac2d06fe23f1f067fa4276d55be3bd8c to your computer and use it in GitHub Desktop.
Save hypeJunction/ac2d06fe23f1f067fa4276d55be3bd8c to your computer and use it in GitHub Desktop.
Dockerfile for monorepo
FROM node:16-alpine as server-builder
WORKDIR /app
COPY . .
RUN --mount=type=cache,target=/app/.yarn/cache \
npx turbo prune --scope=@me/application-a && \
cp -R .yarn .yarnrc.yml tsconfig.json out/ && \
cd out && \
yarn install && \
yarn turbo run build --filter=@me/application-a && \
yarn workspaces focus --all --production && \
rm -rf node_modules/.cache .yarn/cache applications/application-a/.next/cache
FROM node:16-alpine as app
ENV NODE_ENV=production
WORKDIR /app
COPY --chown=node:node --from=server-builder /app/out .
WORKDIR /app/applications/web-server
USER 1000
CMD ["yarn", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment