0
Fork 0
mirror of https://github.com/stonith404/pingvin-share.git synced 2025-01-29 01:28:59 -05:00

performance: reduce docker image size

This commit is contained in:
Elias Schneider 2022-12-08 23:21:31 +01:00
parent b8172efd59
commit d6a88f2a22

View file

@ -1,11 +1,12 @@
FROM node:18-alpine AS frontend-builder
FROM node:18-slim AS frontend-builder
WORKDIR /opt/app
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY ./frontend .
RUN npm run build
FROM node:18 AS backend-builder
FROM node:18-slim AS backend-builder
RUN apt-get update && apt-get install -y openssl
WORKDIR /opt/app
COPY backend/package.json backend/package-lock.json ./
RUN npm ci
@ -13,9 +14,10 @@ COPY ./backend .
RUN npx prisma generate
RUN npm run build
FROM node:18 AS runner
WORKDIR /opt/app/frontend
FROM node:18-slim AS runner
ENV NODE_ENV=production
RUN apt-get update && apt-get install -y openssl
WORKDIR /opt/app/frontend
COPY --from=frontend-builder /opt/app/next.config.js .
COPY --from=frontend-builder /opt/app/public ./public
COPY --from=frontend-builder /opt/app/.next ./.next
@ -26,7 +28,7 @@ COPY --from=backend-builder /opt/app/node_modules ./node_modules
COPY --from=backend-builder /opt/app/dist ./dist
COPY --from=backend-builder /opt/app/prisma ./prisma
COPY --from=backend-builder /opt/app/package.json ./
WORKDIR /opt/app
WORKDIR /opt/app
EXPOSE 3000
CMD cd frontend && node_modules/.bin/next start & cd backend && npm run prod