diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1b834d2 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index b8d84a1..f5c3061 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,23 @@ version: "3.8" 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: image: postgres:15 environment: