diff --git a/Dockerfile b/Dockerfile.backend similarity index 100% rename from Dockerfile rename to Dockerfile.backend diff --git a/Dockerfile.frontend b/Dockerfile.frontend new file mode 100644 index 0000000..2dbb372 --- /dev/null +++ b/Dockerfile.frontend @@ -0,0 +1,12 @@ +FROM node:latest as build-stage +WORKDIR /app +COPY ./web/package*.json ./ +COPY ./.env ./ +RUN npm ci +COPY ./web/ . +RUN npm run build + +FROM nginx as production-stage +RUN mkdir /app +COPY --from=build-stage /app/dist /app +COPY ./web/nginx.conf /etc/nginx/nginx.conf diff --git a/README.MD b/README.MD index cd79315..25abb7b 100644 --- a/README.MD +++ b/README.MD @@ -12,6 +12,8 @@ ### For website - API_ADDRESS +- FRONT_PORT +- FRONT_BASE_PATH ## Usage diff --git a/docker-compose.yml b/docker-compose.yml index ad8c7f9..da4f958 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,9 @@ services: timeout: 30s retries: 10 backend: - build: . + build: + context: ./ + dockerfile: ./Dockerfile.backend image: parismuseesquizz-backend depends_on: db: @@ -29,6 +31,18 @@ services: - back-net ports: - "${API_PORT}:${API_PORT}" + frontend: + build: + context: ./ + dockerfile: ./Dockerfile.frontend + image: parismuseesquizz-frontend + env_file: + - .env + ports: + - "${FRONT_PORT}:80" + networks: + - front-net networks: back-net: + front-net: diff --git a/web/index.html b/web/index.html index d96e085..b3636c3 100644 --- a/web/index.html +++ b/web/index.html @@ -4,7 +4,7 @@ - Vite App + Quizz Paris Musées
diff --git a/web/nginx.conf b/web/nginx.conf new file mode 100644 index 0000000..385df25 --- /dev/null +++ b/web/nginx.conf @@ -0,0 +1,30 @@ +user nginx; +worker_processes 1; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; +events { + worker_connections 1024; +} +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + sendfile on; + keepalive_timeout 65; + server { + listen 80; + server_name localhost; + location / { + root /app; + index index.html; + try_files $uri $uri/ /index.html; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } +} \ No newline at end of file diff --git a/web/src/components/Learn.vue b/web/src/components/Learn.vue deleted file mode 100644 index e69de29..0000000 diff --git a/web/vite.config.ts b/web/vite.config.ts index e1b5ec1..6396804 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -21,5 +21,6 @@ export default defineConfig(({ command, mode }): UserConfig => { ...env2, }, }, + base: env1.FRONT_BASE_PATH ?? env2.FRONT_BASE_PATH ?? "/", } })