Files
recipe-app/backend/Dockerfile
T
2026-04-15 21:08:07 +02:00

34 lines
861 B
Docker

# Byggas från backend-mappen: docker build -t recipe-api:local .
# Stage 1: Bygg applikationen
FROM node:22-alpine AS builder
WORKDIR /app
# Kopiera backend-filer
COPY package.json ./
COPY prisma ./prisma
COPY prisma.config.ts ./
COPY src ./src
COPY tsconfig.json ./
COPY nest-cli.json ./
# Köra npm install
RUN npm install
RUN npx prisma generate
RUN npm run build
# Stage 2: Kör applikationen
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/prisma.config.ts ./prisma.config.ts
COPY --from=builder /app/dist ./dist
EXPOSE 8080
CMD ["sh", "-c", "until npx prisma migrate deploy; do echo 'Migration failed, retrying in 5s...'; sleep 5; done && node dist/main"]