eg3 finished Backend only

master
Jason Zhu 2023-05-04 23:45:36 +10:00
parent 155195ddda
commit 72a0a57842
7 changed files with 42 additions and 28 deletions

View File

@ -2,3 +2,10 @@
[How To Run Multiple Docker Containers Under One URL](https://codingwithmanny.medium.com/create-an-nginx-reverse-proxy-with-docker-a1c0aa9078f1)
## Backend only
How to test it:
1. Comment all other containers
2. Run `docker compose build` & `docker compose up`
3. Test by `curl localhost:5000`, should return `{"version":"1.0.0"}`

View File

@ -1,8 +0,0 @@
version: '3.8'
services:
backend:
container_name: backend
build: .
ports:
- "5000:5000"

View File

@ -0,0 +1,27 @@
version: '3.8'
services:
# proxy:
# container_name: proxy
# build:
# context: ./proxy
# dockerfile: Dockerfile
# ports:
# - "80:80"
# depends_on:
# - frontend
# - backend
# frontend:
# container_name: frontend
# build:
# context: ./frontend
# dockerfile: Dockerfile
backend:
container_name: backend
build:
context: ./backend
dockerfile: Dockerfile
ports:
- "5000:5000" # Uncomment this line if you want to run the backend container only

View File

@ -1,8 +0,0 @@
version: '3.8'
services:
frontend:
container_name: frontend
build: .
# ports:
# - "80:80"

View File

@ -1,4 +1,9 @@
FROM nginx:stable-alpine
WORKDIR /etc/nginx/conf.d
COPY default.conf .
CMD [ "nginx", "-s", "reload"]
COPY default.conf /etc/nginx/conf.d
EXPOSE 80/tcp
EXPOSE 443/tcp
CMD [ "/bin/sh", "-c", "exec nginx -g 'daemon off;';"]
WORKDIR /usr/share/nginx/html

View File

@ -1,6 +1,5 @@
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {

View File

@ -1,8 +0,0 @@
version: '3.8'
services:
proxy:
container_name: proxy
build: .
ports:
- "80:80"