Skip to content

Instantly share code, notes, and snippets.

@Tsugami
Created August 31, 2021 03:02
Show Gist options
  • Save Tsugami/e6270dac09a5ec86d9a11b20c003ebd2 to your computer and use it in GitHub Desktop.
Save Tsugami/e6270dac09a5ec86d9a11b20c003ebd2 to your computer and use it in GitHub Desktop.
monorepo dockerfile
FROM node:lts as builder
ENV NODE_ENV=production
WORKDIR /app
COPY package.json /app
COPY yarn.lock /app
COPY tsconfig.base.json /app
COPY /apps /app/apps
RUN --mount=type=cache,id=fem-builder-yarn,uid=1000,gid=1000,target=/home/node/.yarn YARN_CACHE_FOLDER=/home/node/.yarn yarn install --production=false --frozen-lockfile
RUN --mount=type=cache,id=fem-builder-yarn,uid=1000,gid=1000,target=/home/node/.yarn YARN_CACHE_FOLDER=/home/node/.yarn yarn server:build
FROM node:lts as prod-server
ENV NODE_ENV=production
ENV PORT=3333
ARG MONGO_URI=none
ENV MONGO_URI=$MONGO_URI
ARG JWT_SECRET=secret
ENV JWT_SECRET=$JWT_SECRET
WORKDIR /prod
COPY --from=builder /app /prod
RUN --mount=type=cache,id=fem-runner-yarn,uid=1000,gid=1000,target=/home/node/.yarn YARN_CACHE_FOLDER=/home/node/.yarn yarn install --production --frozen-lockfile --ignore-scripts --prefer-offline
EXPOSE 3333
CMD yarn server:start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment