waterwolf-auth/apps/backend/Dockerfile

40 lines
940 B
Text
Raw Permalink Normal View History

2024-10-16 03:36:15 +00:00
# Setup Base Env
FROM node:20.18.0-alpine3.20 AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
2024-10-16 03:36:15 +00:00
COPY . /app
WORKDIR /app
RUN rm -rf /app/node_modules
2024-10-16 03:36:15 +00:00
# Install Prod Dependencies
FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install typia ts-patch -g
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
2024-10-16 03:36:15 +00:00
# Install all Dependencies
FROM base AS all-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
# lint
2024-10-16 03:36:15 +00:00
FROM all-deps AS lint
RUN npm run lint -- --no-fix
2024-10-16 03:36:15 +00:00
#Build the app
FROM all-deps AS build
RUN pnpm run build
2024-10-16 03:36:15 +00:00
#Build final image
FROM base
RUN apk add --no-cache tini
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
ENV NODE_ENV=production
EXPOSE 3000
ENTRYPOINT ["/sbin/tini", "--"]
2024-10-16 03:36:15 +00:00
CMD ["node", "/app/dist/main.js"]
ARG VERSION
ENV VERSION=${VERSION}