waterwolf-auth/Dockerfile
2024-10-15 23:36:15 -04:00

39 lines
No EOL
911 B
Docker

# Setup Base Env
FROM node:20.18.0-alpine3.20 AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY . /app
WORKDIR /app
# 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
# Install all Dependencies
FROM base AS all-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
# lint
FROM all-deps AS lint
RUN npm run lint -- --no-fix
#Build the app
FROM all-deps AS build
RUN pnpm run build
#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", "--"]
CMD ["node", "/app/dist/main.js"]
ARG VERSION
ENV VERSION=${VERSION}