Files
auth-service/Dockerfile
2023-05-25 12:33:21 -04:00

37 lines
1.0 KiB
Docker

ARG ENV=production
ARG MONGO_VERSION
ARG PORT=9001
ARG NPM_TOKEN
ARG YARN_VERSION=3.5.0
## mongo build stage
FROM mongo:${MONGO_VERSION:-latest} AS database
ENV NODE_ENV $ENV
COPY docker-entrypoint-initdb.d/mongo-init-${MONGO_VERSION:-latest}.sh ./docker-entrypoint-initdb.d/mongo-init.sh
## stage one, build the service
FROM node:20-bullseye-slim AS build
ENV YARN_VERSION $YARN_VERSION
ENV NODE_ENV development
ENV NPM_TOKEN $NPM_TOKEN
WORKDIR /home/node/app
COPY .npmrc /root
COPY .build.yarnrc.yml /root/.yarnrc.yml
COPY . .
RUN yarn set version stable && yarn install
RUN yarn build:production
## this is stage two , where the app actually runs
FROM node:20-bullseye-slim AS containerize
ENV YARN_VERSION $YARN_VERSION
ENV NODE_ENV $ENV
ENV NPM_TOKEN $NPM_TOKEN
WORKDIR /home/node/app
COPY .npmrc /root
COPY .build.yarnrc.yml /root/.yarnrc.yml
COPY package*.json yarn.lock ./
RUN yarn set version stable && yarn install && yarn cache clean
COPY --from=build /home/node/app/dist ./
EXPOSE $PORT
CMD ["node","index.js"]