2022-11-13 20:54:10 -05:00
|
|
|
FROM node:19-alpine AS deps
|
2022-04-13 18:31:38 -04:00
|
|
|
|
2022-03-28 19:19:53 -04:00
|
|
|
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
|
|
|
RUN apk add --no-cache libc6-compat git
|
2022-04-13 18:31:38 -04:00
|
|
|
|
2022-03-28 19:19:53 -04:00
|
|
|
WORKDIR /app
|
2022-04-13 18:31:38 -04:00
|
|
|
|
2022-03-28 19:19:53 -04:00
|
|
|
COPY package.json yarn.lock tsconfig.json tslint.json ./
|
2022-04-13 18:31:38 -04:00
|
|
|
|
2022-03-28 19:19:53 -04:00
|
|
|
RUN yarn install --frozen-lockfile
|
|
|
|
|
2022-11-13 20:54:10 -05:00
|
|
|
FROM node:19-alpine AS builder
|
2022-03-28 19:19:53 -04:00
|
|
|
|
|
|
|
WORKDIR /app
|
2022-04-13 18:31:38 -04:00
|
|
|
|
2022-03-28 19:19:53 -04:00
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
|
|
COPY . .
|
2022-04-13 18:31:38 -04:00
|
|
|
|
|
|
|
ARG NODE_ENV
|
|
|
|
|
|
|
|
ENV NODE_ENV=${NODE_ENV:-production}
|
|
|
|
|
2022-03-28 22:26:16 -04:00
|
|
|
RUN apk add --no-cache git
|
2022-04-13 18:31:38 -04:00
|
|
|
RUN yarn build:docker
|
2022-03-28 19:19:53 -04:00
|
|
|
|
2022-11-13 20:54:10 -05:00
|
|
|
FROM node:19-alpine AS runner
|
2022-03-28 19:19:53 -04:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
2022-04-13 18:31:38 -04:00
|
|
|
ARG NODE_ENV
|
|
|
|
|
|
|
|
ENV NODE_ENV=${NODE_ENV:-production}
|
2022-03-28 19:19:53 -04:00
|
|
|
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
|
|
RUN adduser --system --uid 1001 drift
|
|
|
|
|
|
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
|
|
|
|
|
|
USER drift
|
|
|
|
|
2022-04-13 18:31:38 -04:00
|
|
|
ENV PORT=3000
|
2022-03-28 19:19:53 -04:00
|
|
|
|
2022-04-13 18:31:38 -04:00
|
|
|
EXPOSE 3000
|
2022-03-28 19:19:53 -04:00
|
|
|
|
|
|
|
CMD ["node", "dist/index.js"]
|