From 7261c7d2d2311c9cc99dad10623dfbb96007aae4 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 18 Feb 2025 03:04:15 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20fichiers=20Docker=20pour=20la=20co?= =?UTF-8?q?nfiguration=20de=20Traefik=20et=20le=20d=C3=A9ploiement=20de=20?= =?UTF-8?q?l'application=20Next.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compose.yml | 34 ++++++++++++++++++++++++++++++++++ front/Dockerfile | 27 +++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 compose.yml create mode 100644 front/Dockerfile diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..6a434d4 --- /dev/null +++ b/compose.yml @@ -0,0 +1,34 @@ +networks: + default: + +services: + traefik: + container_name: neah-traefik + image: traefik:latest + command: + - "--api.insecure=true" + - "--providers.docker=true" + - "--entrypoints.web.address=:80" + ports: + - "80:80" + - "8080:8080" + volumes: + - /var/run/docker.sock:/var/run/docker.sock + networks: + - default + + front: + container_name: neah-front + build: + context: ./front + dockerfile: Dockerfile + environment: + - NODE_ENV=production + volumes: + - ./front:/app + labels: + - "traefik.enable=true" + - "traefik.http.routers.neah-front.rule=Host(`neah.local`)" + - "traefik.http.services.neah-front.loadbalancer.server.port=3000" + networks: + - default diff --git a/front/Dockerfile b/front/Dockerfile new file mode 100644 index 0000000..ab133e5 --- /dev/null +++ b/front/Dockerfile @@ -0,0 +1,27 @@ +# Use Node.js 22 as the base image +FROM node:22-alpine + +# Set working directory +WORKDIR /application + +# Copy package files first +COPY package*.json ./ + +# Install dependencies +RUN npm ci + +# Copy the rest of the application +COPY . . + +# Build the Next.js application +RUN npm run build + +# Expose port 3000 +EXPOSE 3000 + +# Set environment variable +ENV NODE_ENV production +ENV NEXT_TELEMETRY_DISABLED 1 + +# Start the application and keep the container running even if it fails +CMD ["sh", "-c", "npm start || tail -f /dev/null"] \ No newline at end of file