chore: dockerfile and compose
This commit is contained in:
44
Dockerfile
Normal file
44
Dockerfile
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Stage de build
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Installation de pnpm
|
||||||
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
|
||||||
|
# Copie des fichiers de dépendances
|
||||||
|
COPY package.json pnpm-lock.yaml ./
|
||||||
|
|
||||||
|
# Installation des dépendances
|
||||||
|
RUN pnpm install --frozen-lockfile
|
||||||
|
|
||||||
|
# Copie du code source
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build de l'application
|
||||||
|
RUN pnpm build
|
||||||
|
|
||||||
|
# Stage de production
|
||||||
|
FROM node:20-alpine AS runner
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
# Installation de pnpm
|
||||||
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||||
|
|
||||||
|
# Copie des dépendances de production
|
||||||
|
COPY --from=builder /app/package.json /app/pnpm-lock.yaml ./
|
||||||
|
RUN pnpm install --frozen-lockfile --prod
|
||||||
|
|
||||||
|
# Copie des fichiers nécessaires depuis le stage de build
|
||||||
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder /app/.next ./.next
|
||||||
|
COPY --from=builder /app/next.config.mjs ./
|
||||||
|
|
||||||
|
# Exposition du port
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Commande de démarrage
|
||||||
|
CMD ["pnpm", "start"]
|
||||||
@@ -1,6 +1,23 @@
|
|||||||
version: "3.8"
|
version: "3.8"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
app:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
environment:
|
||||||
|
NODE_ENV: production
|
||||||
|
DB_HOST: postgres
|
||||||
|
DB_PORT: 5432
|
||||||
|
DB_NAME: peakskills
|
||||||
|
DB_USER: peakskills_user
|
||||||
|
DB_PASSWORD: peakskills_password
|
||||||
|
NEXT_PUBLIC_API_URL: ""
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:15
|
image: postgres:15
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user