2022-04-25 15:15:17 +02:00
|
|
|
# Install dependencies only when needed
|
|
|
|
FROM node:16-alpine AS deps
|
|
|
|
WORKDIR /opt/app
|
|
|
|
COPY package.json package-lock.json ./
|
|
|
|
RUN npm ci
|
|
|
|
|
|
|
|
|
2022-05-01 12:12:00 +02:00
|
|
|
FROM node:16-alpine AS script-builder
|
|
|
|
WORKDIR /opt/app
|
|
|
|
COPY .setup .setup
|
|
|
|
WORKDIR /opt/app/.setup
|
|
|
|
RUN npm install
|
|
|
|
RUN npm i -g @vercel/ncc
|
|
|
|
RUN ncc build index.ts
|
|
|
|
|
2022-04-25 15:15:17 +02:00
|
|
|
# Production image, copy all the files and run next
|
|
|
|
FROM node:16-alpine AS runner
|
|
|
|
WORKDIR /opt/app
|
|
|
|
ENV NODE_ENV=production
|
2022-05-01 17:31:30 +02:00
|
|
|
COPY . .
|
|
|
|
COPY --from=deps /opt/app/node_modules ./node_modules
|
2022-05-01 12:12:00 +02:00
|
|
|
COPY --from=script-builder /opt/app/.setup/dist/index.js ./scripts/setup.js
|
|
|
|
|
2022-04-25 15:15:17 +02:00
|
|
|
EXPOSE 3000
|
2022-05-01 17:31:30 +02:00
|
|
|
CMD npm run build && npm start
|