Skip to content

Commit

Permalink
add web server
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan committed Apr 9, 2024
1 parent 11cd05b commit 733891e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 29 deletions.
9 changes: 9 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ services:
- 80:80
depends_on:
- docker-fastapi
web:
container_name: "web"
build:
context: .
dockerfile: ./docker/node/Dockerfile
ports:
- 3000:3000


9 changes: 9 additions & 0 deletions docker/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:latest


WORKDIR /app

COPY ./frontend .
RUN npm install && npm run build
RUN npm install -g serve
CMD serve -s build
28 changes: 14 additions & 14 deletions docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@

FROM node:latest as build_frontend


WORKDIR /app

#COPY ./frontend/package.json ./frontend/package-lock.json /usr/src/app/

COPY ./frontend .
RUN npm install

RUN npm run build
#FROM node:latest as build_frontend
#
#
#WORKDIR /app
#
##COPY ./frontend/package.json ./frontend/package-lock.json /usr/src/app/
#
#COPY ./frontend .
#RUN npm install
#
#RUN npm run build


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

COPY ./docker/nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 80
Expand Down
27 changes: 12 additions & 15 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
upstream docker_fastapi {
server docker-fastapi:8080;
}
upstream web {
server web:3000;
}



server {
listen 80;

location ~ /api/ {
proxy_pass http://docker_fastapi;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
server_name nginx;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
proxy_pass http://web/;
}

error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /usr/share/nginx/html;
location /api/v1 {
proxy_pass http://fastapi_backend/api/v1;
}
}

0 comments on commit 733891e

Please sign in to comment.