Part 2 exercises
This commit is contained in:
parent
108f52dbd5
commit
ad09df6e2b
16 changed files with 266 additions and 0 deletions
9
Part2/Exercise01/docker-compose.yml
Normal file
9
Part2/Exercise01/docker-compose.yml
Normal 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
|
8
Part2/Exercise02/docker-compose.yml
Normal file
8
Part2/Exercise02/docker-compose.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
simple-web-service:
|
||||
image: devopsdockeruh/simple-web-service
|
||||
command: "server"
|
||||
ports:
|
||||
- 8080:8080
|
11
Part2/Exercise03/docker-compose.yml
Normal file
11
Part2/Exercise03/docker-compose.yml
Normal 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
|
16
Part2/Exercise04/docker-compose.yml
Normal file
16
Part2/Exercise04/docker-compose.yml
Normal 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
|
1
Part2/Exercise05/command.txt
Normal file
1
Part2/Exercise05/command.txt
Normal file
|
@ -0,0 +1 @@
|
|||
docker compose up --scale compute=2
|
25
Part2/Exercise06/docker-compose.yml
Normal file
25
Part2/Exercise06/docker-compose.yml
Normal 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
|
28
Part2/Exercise07/docker-compose.yml
Normal file
28
Part2/Exercise07/docker-compose.yml
Normal 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
|
38
Part2/Exercise08/docker-compose.yml
Normal file
38
Part2/Exercise08/docker-compose.yml
Normal 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
|
17
Part2/Exercise08/nginx.conf
Normal file
17
Part2/Exercise08/nginx.conf
Normal 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/;
|
||||
}
|
||||
}
|
||||
}
|
7
Part2/Exercise09/Dockerfile_back
Normal file
7
Part2/Exercise09/Dockerfile_back
Normal 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"]
|
9
Part2/Exercise09/Dockerfile_front
Normal file
9
Part2/Exercise09/Dockerfile_front
Normal 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"]
|
3
Part2/Exercise09/changes.txt
Normal file
3
Part2/Exercise09/changes.txt
Normal 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.
|
38
Part2/Exercise09/docker-compose.yml
Normal file
38
Part2/Exercise09/docker-compose.yml
Normal 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
|
17
Part2/Exercise09/nginx.conf
Normal file
17
Part2/Exercise09/nginx.conf
Normal 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/;
|
||||
}
|
||||
}
|
||||
}
|
38
Part2/Exercise10/docker-compose.yml
Normal file
38
Part2/Exercise10/docker-compose.yml
Normal 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
|
1
Part2/Exercise10/explanation.txt
Normal file
1
Part2/Exercise10/explanation.txt
Normal file
|
@ -0,0 +1 @@
|
|||
I had already naturally removed the ports from the docker-compose.yml when I did the proxy setup.
|
Reference in a new issue