mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: preparation du dockerfile pour le frontend [#13]
This commit is contained in:
36
Front-End/Dockerfile
Normal file
36
Front-End/Dockerfile
Normal file
@ -0,0 +1,36 @@
|
||||
# Build argument pour choisir le mode
|
||||
ARG BUILD_MODE=production
|
||||
|
||||
# Build stage pour production uniquement
|
||||
FROM node:18-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Development stage
|
||||
FROM node:18-alpine AS development
|
||||
ENV NODE_ENV=development
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
# Ajout de la surveillance des fichiers pour le hot reload
|
||||
ENV WATCHPACK_POLLING=true
|
||||
ENV CHOKIDAR_USEPOLLING=true
|
||||
COPY . .
|
||||
EXPOSE 3000
|
||||
CMD ["npm", "run", "dev"]
|
||||
|
||||
# Production stage
|
||||
FROM node:18-alpine AS production
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
EXPOSE 3000
|
||||
CMD ["node", "server.js"]
|
||||
|
||||
# Final stage selection
|
||||
FROM ${BUILD_MODE}
|
||||
@ -1,11 +1,5 @@
|
||||
# A Docker Compose must always start with the version tag.
|
||||
# We use '3' because it's the last version.
|
||||
#version: '3'
|
||||
version: '3'
|
||||
|
||||
# You should know that Docker Compose works with services.
|
||||
# 1 service = 1 container.
|
||||
# For example, a service, a server, a client, a database...
|
||||
# We use the keyword 'services' to start to create services.
|
||||
services:
|
||||
redis:
|
||||
image: 'redis:latest'
|
||||
@ -15,27 +9,14 @@ services:
|
||||
environment:
|
||||
- TZ=Europe/Paris
|
||||
|
||||
# The name of our service is "database"
|
||||
# but you can use the name of your choice.
|
||||
# Note: This may change the commands you are going to use a little bit.
|
||||
database:
|
||||
# Official Postgres image from DockerHub (we use the last version)
|
||||
image: 'postgres:latest'
|
||||
|
||||
# By default, a Postgres database is running on the 5432 port.
|
||||
# If we want to access the database from our computer (outside the container),
|
||||
# we must share the port with our computer's port.
|
||||
# The syntax is [port we want on our machine]:[port we want to retrieve in the container]
|
||||
# Note: You are free to change your computer's port,
|
||||
# but take into consideration that it will change the way
|
||||
# you are connecting to your database.
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
environment:
|
||||
POSTGRES_USER: postgres # The PostgreSQL user (useful to connect to the database)
|
||||
POSTGRES_PASSWORD: postgres # The PostgreSQL password (useful to connect to the database)
|
||||
POSTGRES_DB: school # The PostgreSQL default database (automatically created at first launch)
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: school
|
||||
TZ: Europe/Paris
|
||||
|
||||
backend:
|
||||
@ -56,3 +37,17 @@ services:
|
||||
- database
|
||||
command: python start.py
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./Front-End
|
||||
args:
|
||||
- BUILD_MODE=development
|
||||
ports:
|
||||
- 3000:3000
|
||||
volumes:
|
||||
- ./Front-End:/app
|
||||
environment:
|
||||
- TZ=Europe/Paris
|
||||
depends_on:
|
||||
- backend
|
||||
|
||||
|
||||
Reference in New Issue
Block a user