Skip to content

Commit 733891e

Browse files
author
Alan
committed
add web server
1 parent 11cd05b commit 733891e

File tree

4 files changed

+44
-29
lines changed

4 files changed

+44
-29
lines changed

docker-compose.yaml

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

docker/frontend/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM node:latest
2+
3+
4+
WORKDIR /app
5+
6+
COPY ./frontend .
7+
RUN npm install && npm run build
8+
RUN npm install -g serve
9+
CMD serve -s build

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: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
upstream docker_fastapi {
22
server docker-fastapi:8080;
33
}
4+
upstream web {
5+
server web:3000;
6+
}
7+
8+
49

510
server {
611
listen 80;
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-
}
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;
1516

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

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

0 commit comments

Comments
 (0)