1
0
Fork 0

Part 2 exercises

This commit is contained in:
Vili Sinervä 2023-03-15 18:22:26 +02:00
parent 108f52dbd5
commit ad09df6e2b
16 changed files with 266 additions and 0 deletions

View file

@ -0,0 +1,9 @@
version: '3.8'
services:
simple-web-service:
image: devopsdockeruh/simple-web-service
build: .
volumes:
- ./text.log:/usr/src/app/text.log

View file

@ -0,0 +1,8 @@
version: '3.8'
services:
simple-web-service:
image: devopsdockeruh/simple-web-service
command: "server"
ports:
- 8080:8080

View file

@ -0,0 +1,11 @@
version: '3.8'
services:
backend:
image: example-backend:1.14
ports:
- 8080:8080
frontend:
image: example-frontend:1.14
ports:
- 5000:5000

View file

@ -0,0 +1,16 @@
version: '3.8'
services:
backend:
image: example-backend:1.14
ports:
- 8080:8080
environment:
- REDIS_HOST=cache
frontend:
image: example-frontend:1.14
ports:
- 5000:5000
redis:
image: redis:7.0.9
container_name: cache

View file

@ -0,0 +1 @@
docker compose up --scale compute=2

View file

@ -0,0 +1,25 @@
version: '3.9'
services:
db:
image: postgres:15.2-alpine
environment:
- POSTGRES_PASSWORD=postgres
container_name: db
backend:
image: example-backend:1.14
ports:
- 8080:8080
environment:
- REDIS_HOST=cache
- POSTGRES_HOST=db
- POSTGRES_PASSWORD=postgres
depends_on:
- db
frontend:
image: example-frontend:1.14
ports:
- 5000:5000
redis:
image: redis:7.0.9
container_name: cache

View file

@ -0,0 +1,28 @@
version: '3.9'
services:
db:
image: postgres:15.2-alpine
environment:
- POSTGRES_PASSWORD=postgres
container_name: db
volumes:
- ./data:/var/lib/postgresql/data
backend:
image: example-backend:1.14
ports:
- 8080:8080
environment:
- REDIS_HOST=cache
- POSTGRES_HOST=db
- POSTGRES_PASSWORD=postgres
depends_on:
- db
frontend:
image: example-frontend:1.14
ports:
- 5000:5000
redis:
image: redis:7.0.9
container_name: cache

View file

@ -0,0 +1,38 @@
version: '3.9'
services:
db:
image: postgres:15.2-alpine
environment:
- POSTGRES_PASSWORD=postgres
container_name: db
volumes:
- ./data:/var/lib/postgresql/data
backend:
image: example-backend:1.14
environment:
- REDIS_HOST=cache
- POSTGRES_HOST=db
- POSTGRES_PASSWORD=postgres
container_name: back
depends_on:
- db
frontend:
image: example-frontend:1.14
container_name: front
redis:
image: redis:7.0.9
container_name: cache
proxy:
image: nginx:1.23.3
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- 80:80
depends_on:
- backend
- frontend

View file

@ -0,0 +1,17 @@
events { worker_connections 1024; }
http {
server {
listen 80;
location / {
proxy_pass http://front:5000;
}
# configure here where requests to http://localhost/api/...
# are forwarded
location /api/ {
proxy_set_header Host $host;
proxy_pass http://back:8080/;
}
}
}

View file

@ -0,0 +1,7 @@
FROM golang:1.16
EXPOSE 8080
WORKDIR /usr/src/app
COPY . .
ENV REQUEST_ORIGIN=http://devops/
RUN go build
CMD ["./server"]

View file

@ -0,0 +1,9 @@
FROM node:16.19
EXPOSE 5000
WORKDIR /usr/src/app
COPY package*.json ./
COPY . .
ENV REACT_APP_BACKEND_URL=http://devops/api
RUN npm install && npm run build
RUN npm install -g serve
CMD ["serve", "-s", "-l", "5000", "build"]

View file

@ -0,0 +1,3 @@
I changed REQUEST_ORIGIN in the backend from http://devops:5000 to http://devops/ and BACKEND_URL from http://devops:8080 to http://devops/api.
I alson updated the image versions in docker-compose.yml to match the new images.

View file

@ -0,0 +1,38 @@
version: '3.9'
services:
db:
image: postgres:15.2-alpine
environment:
- POSTGRES_PASSWORD=postgres
container_name: db
volumes:
- ./data:/var/lib/postgresql/data
backend:
image: example-backend:2.9
environment:
- REDIS_HOST=cache
- POSTGRES_HOST=db
- POSTGRES_PASSWORD=postgres
container_name: back
depends_on:
- db
frontend:
image: example-frontend:2.9
container_name: front
redis:
image: redis:7.0.9
container_name: cache
proxy:
image: nginx:1.23.3
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- 80:80
depends_on:
- backend
- frontend

View file

@ -0,0 +1,17 @@
events { worker_connections 1024; }
http {
server {
listen 80;
location / {
proxy_pass http://front:5000;
}
# configure here where requests to http://localhost/api/...
# are forwarded
location /api/ {
proxy_set_header Host $host;
proxy_pass http://back:8080/;
}
}
}

View file

@ -0,0 +1,38 @@
version: '3.9'
services:
db:
image: postgres:15.2-alpine
environment:
- POSTGRES_PASSWORD=postgres
container_name: db
volumes:
- ./data:/var/lib/postgresql/data
backend:
image: example-backend:2.9
environment:
- REDIS_HOST=cache
- POSTGRES_HOST=db
- POSTGRES_PASSWORD=postgres
container_name: back
depends_on:
- db
frontend:
image: example-frontend:2.9
container_name: front
redis:
image: redis:7.0.9
container_name: cache
proxy:
image: nginx:1.23.3
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- 80:80
depends_on:
- backend
- frontend

View file

@ -0,0 +1 @@
I had already naturally removed the ports from the docker-compose.yml when I did the proxy setup.