mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-15 01:14:27 -05:00
64 lines
No EOL
1.8 KiB
Docker
64 lines
No EOL
1.8 KiB
Docker
# Stage 1: Frontend dependencies
|
||
FROM node:20-alpine AS frontend-dependencies
|
||
WORKDIR /opt/app
|
||
COPY frontend/package.json frontend/package-lock.json ./
|
||
RUN npm ci
|
||
|
||
# Stage 2: Build frontend
|
||
FROM node:20-alpine AS frontend-builder
|
||
WORKDIR /opt/app
|
||
COPY ./frontend .
|
||
COPY --from=frontend-dependencies /opt/app/node_modules ./node_modules
|
||
RUN npm run build
|
||
|
||
# Stage 3: Backend dependencies
|
||
FROM node:20-alpine AS backend-dependencies
|
||
RUN apk add --no-cache python3
|
||
WORKDIR /opt/app
|
||
COPY backend/package.json backend/package-lock.json ./
|
||
RUN npm ci
|
||
|
||
# Stage 4: Build backend
|
||
FROM node:20-alpine AS backend-builder
|
||
RUN apk add openssl
|
||
|
||
WORKDIR /opt/app
|
||
COPY ./backend .
|
||
COPY --from=backend-dependencies /opt/app/node_modules ./node_modules
|
||
RUN npx prisma generate
|
||
RUN npm run build && npm prune --production
|
||
|
||
# Stage 5: Final image
|
||
FROM node:20-alpine AS runner
|
||
ENV NODE_ENV=docker
|
||
|
||
# Delete default node user
|
||
RUN deluser --remove-home node
|
||
|
||
RUN apk update --no-cache \
|
||
&& apk upgrade --no-cache \
|
||
&& apk add --no-cache curl caddy su-exec openssl
|
||
|
||
WORKDIR /opt/app/frontend
|
||
COPY --from=frontend-builder /opt/app/public ./public
|
||
COPY --from=frontend-builder /opt/app/.next/standalone ./
|
||
COPY --from=frontend-builder /opt/app/.next/static ./.next/static
|
||
COPY --from=frontend-builder /opt/app/public/img /tmp/img
|
||
|
||
WORKDIR /opt/app/backend
|
||
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
|
||
|
||
COPY ./reverse-proxy /opt/app/reverse-proxy
|
||
COPY ./scripts ./scripts
|
||
|
||
EXPOSE 3000
|
||
|
||
HEALTHCHECK --interval=10s --timeout=3s CMD curl -f http://localhost:3000/api/health || exit 1
|
||
|
||
ENTRYPOINT ["sh", "./scripts/docker/create-user.sh"]
|
||
CMD ["sh", "./scripts/docker/entrypoint.sh"] |