Improve project setup with Docker

This commit is contained in:
Elias Schneider
2022-05-01 12:12:00 +02:00
parent 0fd3accaf3
commit d98c31f748
5 changed files with 70 additions and 28 deletions

View File

@@ -11,6 +11,14 @@ COPY . .
COPY --from=deps /opt/app/node_modules ./node_modules
RUN npm run build
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
# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /opt/app
@@ -19,6 +27,13 @@ COPY --from=builder /opt/app/next.config.js ./
COPY --from=builder /opt/app/public ./public
COPY --from=builder /opt/app/.next ./.next
COPY --from=builder /opt/app/node_modules ./node_modules
COPY ./.env ./
COPY --from=script-builder /opt/app/.setup/dist/index.js ./scripts/setup.js
COPY .env.example .env
COPY entrypoint.sh .
RUN apk add --no-cache --upgrade bash
RUN ["chmod", "+x", "./entrypoint.sh"]
ENTRYPOINT ["./entrypoint.sh"]
EXPOSE 3000
CMD ["node_modules/.bin/next", "start"]