Skip to content

Commit 4a9a890

Browse files
author
Alan
committed
add web
1 parent b7ef08f commit 4a9a890

File tree

4 files changed

+29
-43
lines changed

4 files changed

+29
-43
lines changed

docker-compose.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,4 @@ services:
2020
- 80:80
2121
depends_on:
2222
- docker-fastapi
23-
web:
24-
container_name: "web"
25-
build:
26-
context: .
27-
dockerfile: ./docker/frontend/Dockerfile
28-
ports:
29-
- 3000:3000
30-
3123

docker/frontend/Dockerfile

Lines changed: 0 additions & 9 deletions
This file was deleted.

docker/nginx/Dockerfile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11

2-
#FROM node:latest as build_frontend
3-
#
4-
#
5-
#WORKDIR /app
6-
#
7-
##COPY ./frontend/package.json ./frontend/package-lock.json /usr/src/app/
8-
#
9-
#COPY ./frontend .
10-
#RUN npm install
11-
#
12-
#RUN npm run build
2+
FROM node:latest as build_frontend
3+
4+
5+
WORKDIR /app
6+
7+
#COPY ./frontend/package.json ./frontend/package-lock.json /usr/src/app/
8+
9+
COPY ./frontend .
10+
RUN npm install
11+
12+
RUN npm run build
1313

1414

1515
FROM nginx:latest
16-
#RUN rm /usr/share/nginx/html/*
17-
#COPY --from=build_frontend /app/build /usr/share/nginx/html
18-
#RUN rm /etc/nginx/conf.d/default.conf
16+
RUN rm /usr/share/nginx/html/*
17+
COPY --from=build_frontend /app/build /usr/share/nginx/html
18+
RUN rm /etc/nginx/conf.d/default.conf
1919

2020
COPY ./docker/nginx/nginx.conf /etc/nginx/conf.d
2121
EXPOSE 80

docker/nginx/nginx.conf

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
upstream docker_fastapi {
22
server docker-fastapi:8080;
33
}
4-
upstream web {
5-
server web:3000;
6-
}
7-
8-
94

105
server {
116
listen 80;
12-
server_name nginx;
13-
proxy_set_header Host $host;
14-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
15-
proxy_set_header X-Real-IP $remote_addr;
7+
8+
location ~ /api/ {
9+
proxy_pass http://docker_fastapi;
10+
proxy_set_header Host $host;
11+
proxy_set_header X-Real-IP $remote_addr;
12+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13+
proxy_set_header X-Forwarded-Host $server_name;
14+
}
1615

1716
location / {
18-
proxy_pass http://web/;
17+
root /usr/share/nginx/html;
18+
index index.html index.htm;
19+
try_files $uri $uri/ /index.html;
1920
}
2021

21-
location /api/v1 {
22-
proxy_pass http://fastapi_backend/api/v1;
22+
error_page 500 502 503 504 /50x.html;
23+
24+
location = /50x.html {
25+
root /usr/share/nginx/html;
2326
}
2427
}

0 commit comments

Comments
 (0)