├── .gitignore ├── README.md ├── certificate-docker.png ├── part01 ├── 1.1 │ └── ex1.1_getting_started.md ├── 1.10 │ ├── browser_screenshot.png │ └── ex1.10_commands.md ├── 1.11 │ └── Dockerfile ├── 1.12 │ ├── Dockerfile │ └── ex1.12_commands.md ├── 1.13 │ ├── Dockerfile │ └── ex1.13_commands.md ├── 1.14 │ ├── backend │ │ ├── Dockerfile │ │ └── ex1.14_commands.md │ ├── ex1.14_success_screenshot.png │ └── frontend │ │ ├── Dockerfile │ │ └── ex1.14_commands.md ├── 1.15 │ └── README.md ├── 1.16 │ └── README.md ├── 1.2 │ └── ex1.2_cleanup.md ├── 1.3 │ ├── 1.3_commands.md │ └── 1.3_secret_message.txt ├── 1.4 │ └── ex1.4_missing_dependencies.md ├── 1.5 │ └── ex1.5_sizes_of_image.md ├── 1.6 │ └── ex1.6_hello_docker_hub.md ├── 1.7 │ ├── Dockerfile │ └── ex1.7_commands.md ├── 1.8 │ ├── Dockerfile │ ├── ex1.8_commands.md │ └── script.sh └── 1.9 │ ├── ex1.9_command_list.md │ └── text.log ├── part02 ├── 2.1 │ ├── docker-compose.yml │ └── text.log ├── 2.10 │ ├── backend │ │ └── Dockerfile │ ├── docker-compose.yml │ ├── ex_2_10_screenshot.png │ ├── explanation.txt │ └── nginx.conf ├── 2.11 │ ├── flask-dev-env │ │ ├── .gitignore │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── docker-compose.yml │ │ ├── requirements.txt │ │ └── src │ │ │ └── app.py │ └── work.md ├── 2.2 │ └── docker-compose.yml ├── 2.3 │ └── docker-compose.yml ├── 2.4 │ └── docker-compose.yml ├── 2.5 │ ├── docker-compose.yml │ ├── ex2.5_commands.md │ ├── ex2_5_screenshot_01.png │ └── ex2_5_screenshot_02png ├── 2.6 │ └── docker-compose.yml ├── 2.7 │ ├── docker-compose.yml │ └── ex_2_7_screenshot.png ├── 2.8 │ ├── docker-compose.yml │ └── nginx.conf └── 2.9 │ ├── docker-compose.yml │ └── nginx.conf └── part03 ├── 3.1 ├── build.yml └── ex_3_1_screenshot.png ├── 3.3 ├── backend │ └── Dockerfile └── frontend │ └── Dockerfile ├── 3.4 ├── backend │ └── Dockerfile ├── ex_3_4_after.png ├── ex_3_4_before.png └── frontend │ └── Dockerfile ├── 3.5 ├── backend │ └── Dockerfile ├── ex_3_5_after.png ├── ex_3_5_before.png └── frontend │ └── Dockerfile ├── 3.6 ├── backend │ └── Dockerfile ├── docker-compose.yml ├── ex_3_6_after.png ├── ex_3_6_before.png └── frontend │ └── Dockerfile ├── 3.7 ├── Dockerfile ├── Dockerfile_without_optimized └── ex_3_7.PNG └── 3.8 ├── kubernetes.drawio └── kubernetes.drawio.png /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Devops with Docker 2021 2 | 3 | **My submissions to the exercises from https://devopswithdocker.com/** 4 | 5 | Contents: 6 | 7 | - [**_Part 01_**](https://github.com/faayam/devops-with-docker/tree/main/part01) 8 | - [**_Part 02_**](https://github.com/faayam/devops-with-docker/tree/main/part02) 9 | - [**_Part 03_**](https://github.com/faayam/devops-with-docker/tree/main/part03) 10 | 11 | ## Course Certificate 12 | 13 | [**_Link_**](https://studies.cs.helsinki.fi/stats/api/certificate/docker2021/en/769be2597f33793a3ad39cd4a2a76329) 14 | 15 | ![Certificate Screenshot](https://github.com/faayam/devops-with-docker/blob/main/certificate-docker.png) 16 | 17 | ## Author 18 | 19 | - [@faayam](https://www.github.com/faayam) 20 | -------------------------------------------------------------------------------- /certificate-docker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/certificate-docker.png -------------------------------------------------------------------------------- /part01/1.1/ex1.1_getting_started.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~/Code/devops-with-docker/part01 $ docker ps -a 3 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4 | 59237f5f4af5 nginx "/docker-entrypoint.…" 2 minutes ago Up 2 minutes 80/tcp reverent_moore 5 | da66b1555abc nginx "/docker-entrypoint.…" 4 minutes ago Exited (0) 2 minutes ago ecstatic_elbakyan 6 | 2ff96829db4b nginx "/docker-entrypoint.…" 5 minutes ago Exited (0) 5 minutes ago bold_kapitsa 7 | ``` 8 | -------------------------------------------------------------------------------- /part01/1.10/browser_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part01/1.10/browser_screenshot.png -------------------------------------------------------------------------------- /part01/1.10/ex1.10_commands.md: -------------------------------------------------------------------------------- 1 | ```console 2 | 3 | ~/Code/devops-with-docker/part01 $ docker run -p 8080:8080 web-server 4 | [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. 5 | 6 | [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. 7 | - using env: export GIN_MODE=release 8 | - using code: gin.SetMode(gin.ReleaseMode) 9 | 10 | [GIN-debug] GET /*path --> server.Start.func1 (3 handlers) 11 | [GIN-debug] Listening and serving HTTP on :8080 12 | [GIN] 2021/03/20 - 16:45:43 | 200 | 183.049µs | 172.17.0.1 | GET "/" 13 | ``` 14 | -------------------------------------------------------------------------------- /part01/1.11/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8 2 | 3 | EXPOSE 8080 4 | WORKDIR /usr/src/app 5 | 6 | COPY . . 7 | 8 | RUN ./mvnw package 9 | 10 | CMD ["java", "-jar", "./target/docker-example-1.1.3.jar"] 11 | 12 | -------------------------------------------------------------------------------- /part01/1.12/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | WORKDIR /usr/src/app 4 | 5 | EXPOSE 5000 6 | 7 | RUN apt-get update 8 | RUN apt-get install -y curl 9 | 10 | RUN curl -sL https://deb.nodesource.com/setup_14.x | bash 11 | RUN apt install -y nodejs 12 | 13 | COPY . . 14 | 15 | RUN npm install 16 | RUN npm run build 17 | RUN npm install -g serve 18 | 19 | CMD [ "serve", "-s", "-l", "5000", "build" ] -------------------------------------------------------------------------------- /part01/1.12/ex1.12_commands.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~/Code/devops-with-docker/part01/1.12 $ docker build . -t frontend 3 | ~/Code/devops-with-docker/part01/1.12 $ docker run -p 5000:5000 frontend 4 | ``` 5 | -------------------------------------------------------------------------------- /part01/1.13/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.15 2 | 3 | WORKDIR /usr/src/app 4 | EXPOSE 8080 5 | COPY . . 6 | 7 | RUN go build 8 | 9 | CMD ./server -------------------------------------------------------------------------------- /part01/1.13/ex1.13_commands.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~/Code/devops-with-docker/part01/1.13 $ docker build . -t backend 3 | ~/Code/devops-with-docker/part01/1.13 $ docker run -p 8080:8080 backend 4 | ``` 5 | -------------------------------------------------------------------------------- /part01/1.14/backend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.15 2 | 3 | WORKDIR /usr/src/app 4 | EXPOSE 8080 5 | ENV REQUEST_ORIGIN=http://localhost:5000 6 | 7 | COPY . . 8 | 9 | RUN go build 10 | 11 | CMD ./server -------------------------------------------------------------------------------- /part01/1.14/backend/ex1.14_commands.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~/Code/devops-with-docker/part01/1.14/backend $ docker build . -t backend 3 | ~/Code/devops-with-docker/part01/1.14/backend $ docker run -p 8080:8080 backend 4 | 5 | ``` 6 | -------------------------------------------------------------------------------- /part01/1.14/ex1.14_success_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part01/1.14/ex1.14_success_screenshot.png -------------------------------------------------------------------------------- /part01/1.14/frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | WORKDIR /usr/src/app 4 | 5 | EXPOSE 5000 6 | ENV REACT_APP_BACKEND_URL=http://localhost:8080 7 | 8 | RUN apt-get update 9 | RUN apt-get install -y curl 10 | 11 | RUN curl -sL https://deb.nodesource.com/setup_14.x | bash 12 | RUN apt install -y nodejs 13 | 14 | COPY . . 15 | 16 | RUN npm install 17 | RUN npm run build 18 | RUN npm install -g serve 19 | 20 | CMD [ "serve", "-s", "-l", "5000", "build" ] -------------------------------------------------------------------------------- /part01/1.14/frontend/ex1.14_commands.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~/Code/devops-with-docker/part01/1.14/frontend $ docker build . -t frontend 3 | ~/Code/devops-with-docker/part01/1.14/frontend $ docker run -p 5000:5000 frontend 4 | ``` 5 | -------------------------------------------------------------------------------- /part01/1.15/README.md: -------------------------------------------------------------------------------- 1 | ## Exercise 1.15: Homework 2 | 3 | **Docker Hub Link:** https://hub.docker.com/r/faysalmehedi/web-server-test 4 | 5 | _Please follow the following instructions to run the docker images on the local machine:_ 6 | 7 | - Make sure docker installed in the local machine. 8 | - Pull the docker image from the docker hub repo 9 | 10 | ```console 11 | $ docker pull faysalmehedi/web-server-test:latest 12 | ``` 13 | 14 | - Run the image on the local machine as container 15 | 16 | ```console 17 | $ docker run -p 8080:8080 faysalmehedi/web-server-test:latest 18 | ``` 19 | 20 | - Access the application from http://localhost:8080 21 | -------------------------------------------------------------------------------- /part01/1.16/README.md: -------------------------------------------------------------------------------- 1 | ## Exercise 1.16: Heroku 2 | 3 | _Commands I used to publish the existing docker-image `devopsdockeruh/heroku-example` to heroku. First I created a free account on heroku and install heroku cli on my machine._ 4 | 5 | ```console 6 | $ docker pull devopsdockeruh/heroku-example 7 | $ heroku login 8 | $ heroku container:login 9 | $ docker tag devopsdockeruh/heroku-example registry.heroku.com/dwd-herokuexample/web 10 | $ docker push registry.heroku.com/dwd-herokuexample/web 11 | $ heroku container:release -a dwd-herokuexample web 12 | ``` 13 | 14 | **Link to the heroku app: https://dwd-herokuexample.herokuapp.com/** 15 | -------------------------------------------------------------------------------- /part01/1.2/ex1.2_cleanup.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~/Code/devops-with-docker/part01 $ docker ps -a 3 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4 | ~/Code/devops-with-docker/part01 $ docker images 5 | REPOSITORY TAG IMAGE ID CREATED SIZE 6 | ~/Code/devops-with-docker/part01 $ 7 | ``` -------------------------------------------------------------------------------- /part01/1.3/1.3_commands.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~ $ docker run -d --name ex1.3 devopsdockeruh/simple-web-service:ubuntu 3 | 160b40af77e9733602ff38d6fa85b4b272113c3092e8718f92de50170041d2d1 4 | ~ $ docker ps 5 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6 | 160b40af77e9 devopsdockeruh/simple-web-service:ubuntu "/usr/src/app/server" 42 seconds ago Up 39 seconds ex1.3 7 | ~ $ docker exec -it ex1.3 bash 8 | root@160b40af77e9:/usr/src/app# ls 9 | server text.log 10 | root@160b40af77e9:/usr/src/app# tail -f ./text.log 11 | 2021-03-18 18:12:52 +0000 UTC 12 | 2021-03-18 18:12:54 +0000 UTC 13 | 2021-03-18 18:12:56 +0000 UTC 14 | 2021-03-18 18:12:58 +0000 UTC 15 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 16 | 2021-03-18 18:13:00 +0000 UTC 17 | 2021-03-18 18:13:02 +0000 UTC 18 | 2021-03-18 18:13:04 +0000 UTC 19 | 2021-03-18 18:13:06 +0000 UTC 20 | 2021-03-18 18:13:08 +0000 UTC 21 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 22 | 2021-03-18 18:13:10 +0000 UTC 23 | 2021-03-18 18:13:12 +0000 UTC 24 | ^C 25 | root@160b40af77e9:/usr/src/app# 26 | 27 | ``` -------------------------------------------------------------------------------- /part01/1.3/1.3_secret_message.txt: -------------------------------------------------------------------------------- 1 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 2 | -------------------------------------------------------------------------------- /part01/1.4/ex1.4_missing_dependencies.md: -------------------------------------------------------------------------------- 1 | _Terminal 01:_ 2 | 3 | ```console 4 | ~ $ docker run -it --name ex1.4 ubuntu sh -c 'echo "Input website:"; read website; echo "Searching.."; sleep 1; curl http://$website;' 5 | 6 | Input website: 7 | (terminal is waiting for the input, meanwhile to make things right I open another terminal window) 8 | (going to terminal 02) 9 | 10 | helsinki.fi 11 | Searching.. 12 | 13 | 14 | 15 | 301 Moved Permanently 16 | 17 |

Moved Permanently

18 |

The document has moved here.

19 | 20 | 21 | ~ $ 22 | ~ $ docker ps -a 23 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 24 | 297b73c70c44 ubuntu "sh -c 'apt update;a…" 7 minutes ago Exited (0) 5 minutes ago ex1.4 25 | 160b40af77e9 devopsdockeruh/simple-web-service:ubuntu "/usr/src/app/server" 34 minutes ago Up 34 minutes ex1.3 26 | ``` 27 | 28 | _Terminal 02:_ 29 | 30 | ```console 31 | ~ $ docker exec -it ex1.4 bash 32 | root@297b73c70c44:/# ~ $ apt update 33 | root@297b73c70c44:/# ~ $ apt install curl 34 | 35 | (after update ubuntu and installing curl, going back to terminal 01) 36 | ``` 37 | -------------------------------------------------------------------------------- /part01/1.5/ex1.5_sizes_of_image.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~ $ docker pull devopsdockeruh/simple-web-service:alpine 3 | alpine: Pulling from devopsdockeruh/simple-web-service 4 | ba3557a56b15: Pull complete 5 | 1dace236434b: Pull complete 6 | 4f4fb700ef54: Pull complete 7 | Digest: sha256:dd4d367476f86b7d7579d3379fe446ae5dfce25480903fb0966fc2e5257e0543 8 | Status: Downloaded newer image for devopsdockeruh/simple-web-service:alpine 9 | docker.io/devopsdockeruh/simple-web-service:alpine 10 | ~ $ docker images 11 | REPOSITORY TAG IMAGE ID CREATED SIZE 12 | devopsdockeruh/simple-web-service ubuntu 4e3362e907d5 4 days ago 83MB 13 | devopsdockeruh/simple-web-service alpine fd312adc88e0 4 days ago 15.7MB 14 | ~ $ docker run -d --name alpine devopsdockeruh/simple-web-service:alpine 15 | d11f3e3e0a79665a086f6a956b46bc5fa0bbeb04ddc6596403a5dcda0b20eb60 16 | ~ $ docker ps 17 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 18 | d11f3e3e0a79 devopsdockeruh/simple-web-service:alpine "/usr/src/app/server" 7 seconds ago Up 3 seconds alpine 19 | ~ $ docker exec -it alpine sh 20 | /usr/src/app # ls 21 | server text.log 22 | /usr/src/app # tail -f ./text.log 23 | 2021-03-19 11:41:51 +0000 UTC 24 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 25 | 2021-03-19 11:41:53 +0000 UTC 26 | 2021-03-19 11:41:55 +0000 UTC 27 | 2021-03-19 11:41:57 +0000 UTC 28 | 2021-03-19 11:41:59 +0000 UTC 29 | 2021-03-19 11:42:01 +0000 UTC 30 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 31 | 2021-03-19 11:42:03 +0000 UTC 32 | 2021-03-19 11:42:05 +0000 UTC 33 | 2021-03-19 11:42:07 +0000 UTC 34 | ^C 35 | /usr/src/app # 36 | ``` 37 | -------------------------------------------------------------------------------- /part01/1.6/ex1.6_hello_docker_hub.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~ $ docker run -it devopsdockeruh/pull_exercise 3 | Unable to find image 'devopsdockeruh/pull_exercise:latest' locally 4 | latest: Pulling from devopsdockeruh/pull_exercise 5 | 8e402f1a9c57: Pull complete 6 | 5e2195587d10: Pull complete 7 | 6f595b2fc66d: Pull complete 8 | 165f32bf4e94: Pull complete 9 | 67c4f504c224: Pull complete 10 | Digest: sha256:7c0635934049afb9ca0481fb6a58b16100f990a0d62c8665b9cfb5c9ada8a99f 11 | Status: Downloaded newer image for devopsdockeruh/pull_exercise:latest 12 | Give me the password: basics 13 | You found the correct password. Secret message is: 14 | "This is the secret message" 15 | 16 | ``` 17 | -------------------------------------------------------------------------------- /part01/1.7/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM devopsdockeruh/simple-web-service:alpine 2 | 3 | CMD server 4 | -------------------------------------------------------------------------------- /part01/1.7/ex1.7_commands.md: -------------------------------------------------------------------------------- 1 | ```console 2 | 3 | ~/Code/devops-with-docker/part01/1.7 $ docker build . -t web-server 4 | Sending build context to Docker daemon 2.048kB 5 | Step 1/2 : FROM devopsdockeruh/simple-web-service:alpine 6 | ---> fd312adc88e0 7 | Step 2/2 : CMD server 8 | ---> Running in 2ee3b982adfd 9 | Removing intermediate container 2ee3b982adfd 10 | ---> f34ee0431e36 11 | Successfully built f34ee0431e36 12 | Successfully tagged web-server:latest 13 | ~/Code/devops-with-docker/part01/1.7 $ docker images 14 | REPOSITORY TAG IMAGE ID CREATED SIZE 15 | web-server latest f34ee0431e36 16 seconds ago 15.7MB 16 | devopsdockeruh/simple-web-service alpine fd312adc88e0 4 days ago 15.7MB 17 | 18 | ~/Code/devops-with-docker/part01/1.7 $ docker run web-server 19 | [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. 20 | 21 | [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. 22 | - using env: export GIN_MODE=release 23 | - using code: gin.SetMode(gin.ReleaseMode) 24 | 25 | [GIN-debug] GET /*path --> server.Start.func1 (3 handlers) 26 | [GIN-debug] Listening and serving HTTP on :8080 27 | 28 | ``` 29 | -------------------------------------------------------------------------------- /part01/1.8/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | WORKDIR /usr/src/app 4 | 5 | COPY script.sh . 6 | RUN chmod +x script.sh 7 | 8 | RUN apt update 9 | RUN apt install curl -y 10 | 11 | CMD ./script.sh 12 | -------------------------------------------------------------------------------- /part01/1.8/ex1.8_commands.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~/Code/devops-with-docker/part01/1.8 $ docker build . -t curler 3 | ~/Code/devops-with-docker/part01/1.8 $ docker images 4 | REPOSITORY TAG IMAGE ID CREATED SIZE 5 | curler latest 9aa718c6fc90 About a minute ago 116MB 6 | ubuntu 18.04 329ed837d508 2 weeks ago 63.3MB 7 | ~/Code/devops-with-docker/part01/1.8 $ docker run -it curler 8 | Input website: 9 | helsinki.fi 10 | Searching.. 11 | 12 | 13 | 301 Moved Permanently 14 | 15 |

Moved Permanently

16 |

The document has moved here.

17 | 18 | ~/Code/devops-with-docker/part01/1.8 $ 19 | ``` 20 | -------------------------------------------------------------------------------- /part01/1.8/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Input website:" 4 | read website 5 | echo "Searching.." 6 | sleep 1 7 | curl http://$website; 8 | -------------------------------------------------------------------------------- /part01/1.9/ex1.9_command_list.md: -------------------------------------------------------------------------------- 1 | ```console 2 | ~/Code/devops-with-docker/part01/1.9 $ touch text.log 3 | ~/Code/devops-with-docker/part01/1.9 $ ls 4 | text.log 5 | ~/Code/devops-with-docker/part01/1.9 $ docker run -d -v "$(pwd)/text.log://usr/src/app/text.log" devopsdockeruh/simple-web-service:alpine 6 | 1917d75dfd572773739b730965259153e11d0804e17eada8418ed8b9872c550d 7 | ~/Code/devops-with-docker/part01/1.9 $ tail -f ./text.log 8 | 2021-03-20 16:32:04 +0000 UTC 9 | 2021-03-20 16:32:06 +0000 UTC 10 | 2021-03-20 16:32:08 +0000 UTC 11 | 2021-03-20 16:32:10 +0000 UTC 12 | 2021-03-20 16:32:12 +0000 UTC 13 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 14 | 2021-03-20 16:32:14 +0000 UTC 15 | 2021-03-20 16:32:16 +0000 UTC 16 | 2021-03-20 16:32:18 +0000 UTC 17 | 2021-03-20 16:32:20 +0000 UTC 18 | 2021-03-20 16:32:22 +0000 UTC 19 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 20 | 2021-03-20 16:32:24 +0000 UTC 21 | ^C 22 | ~/Code/devops-with-docker/part01/1.9 $ 23 | ~/Code/devops-with-docker/part01/1.9 $ docker ps 24 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 25 | 1917d75dfd57 devopsdockeruh/simple-web-service:alpine "/usr/src/app/server" About a minute ago Up About a minute unruffled_lalande 26 | 8f52d2883a1b ubuntu:18.04 "/bin/bash" 4 hours ago Up 4 hours epic_ptolemy 27 | ~/Code/devops-with-docker/part01/1.9 $ 28 | 29 | ``` 30 | -------------------------------------------------------------------------------- /part01/1.9/text.log: -------------------------------------------------------------------------------- 1 | 2021-03-20 16:32:04 +0000 UTC 2 | 2021-03-20 16:32:06 +0000 UTC 3 | 2021-03-20 16:32:08 +0000 UTC 4 | 2021-03-20 16:32:10 +0000 UTC 5 | 2021-03-20 16:32:12 +0000 UTC 6 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 7 | 2021-03-20 16:32:14 +0000 UTC 8 | 2021-03-20 16:32:16 +0000 UTC 9 | 2021-03-20 16:32:18 +0000 UTC 10 | 2021-03-20 16:32:20 +0000 UTC 11 | 2021-03-20 16:32:22 +0000 UTC 12 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 13 | 2021-03-20 16:32:24 +0000 UTC 14 | 2021-03-20 16:32:26 +0000 UTC 15 | 2021-03-20 16:32:28 +0000 UTC 16 | 2021-03-20 16:32:30 +0000 UTC 17 | 2021-03-20 16:32:32 +0000 UTC 18 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 19 | 2021-03-20 16:32:34 +0000 UTC 20 | 2021-03-20 16:32:36 +0000 UTC 21 | 2021-03-20 16:32:38 +0000 UTC 22 | 2021-03-20 16:32:40 +0000 UTC 23 | 2021-03-20 16:32:42 +0000 UTC 24 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 25 | 2021-03-20 16:32:44 +0000 UTC 26 | 2021-03-20 16:32:46 +0000 UTC 27 | 2021-03-20 16:32:48 +0000 UTC 28 | 2021-03-20 16:32:50 +0000 UTC 29 | 2021-03-20 16:32:52 +0000 UTC 30 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 31 | 2021-03-20 16:32:54 +0000 UTC 32 | 2021-03-20 16:32:56 +0000 UTC 33 | 2021-03-20 16:32:58 +0000 UTC 34 | 2021-03-20 16:33:00 +0000 UTC 35 | 2021-03-20 16:33:02 +0000 UTC 36 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 37 | 2021-03-20 16:33:04 +0000 UTC 38 | 2021-03-20 16:33:06 +0000 UTC 39 | 2021-03-20 16:33:08 +0000 UTC 40 | 2021-03-20 16:33:10 +0000 UTC 41 | 2021-03-20 16:33:12 +0000 UTC 42 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 43 | 2021-03-20 16:33:14 +0000 UTC 44 | 2021-03-20 16:33:16 +0000 UTC 45 | 2021-03-20 16:33:18 +0000 UTC 46 | 2021-03-20 16:33:20 +0000 UTC 47 | 2021-03-20 16:33:22 +0000 UTC 48 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 49 | 2021-03-20 16:33:24 +0000 UTC 50 | 2021-03-20 16:33:26 +0000 UTC 51 | 2021-03-20 16:33:28 +0000 UTC 52 | 2021-03-20 16:33:30 +0000 UTC 53 | 2021-03-20 16:33:32 +0000 UTC 54 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 55 | 2021-03-20 16:33:34 +0000 UTC 56 | 2021-03-20 16:33:36 +0000 UTC 57 | 2021-03-20 16:33:38 +0000 UTC 58 | 2021-03-20 16:33:40 +0000 UTC 59 | 2021-03-20 16:33:42 +0000 UTC 60 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 61 | 2021-03-20 16:33:44 +0000 UTC 62 | 2021-03-20 16:33:46 +0000 UTC 63 | 2021-03-20 16:33:48 +0000 UTC 64 | 2021-03-20 16:33:50 +0000 UTC 65 | 2021-03-20 16:33:52 +0000 UTC 66 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 67 | 2021-03-20 16:33:54 +0000 UTC 68 | 2021-03-20 16:33:56 +0000 UTC 69 | 2021-03-20 16:33:58 +0000 UTC 70 | 2021-03-20 16:34:00 +0000 UTC 71 | 2021-03-20 16:34:02 +0000 UTC 72 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 73 | 2021-03-20 16:34:04 +0000 UTC 74 | 2021-03-20 16:34:06 +0000 UTC 75 | 2021-03-20 16:34:08 +0000 UTC 76 | 2021-03-20 16:34:10 +0000 UTC 77 | 2021-03-20 16:34:12 +0000 UTC 78 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 79 | 2021-03-20 16:34:14 +0000 UTC 80 | 2021-03-20 16:34:16 +0000 UTC 81 | 2021-03-20 16:34:18 +0000 UTC 82 | 2021-03-20 16:34:20 +0000 UTC 83 | 2021-03-20 16:34:22 +0000 UTC 84 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 85 | 2021-03-20 16:34:24 +0000 UTC 86 | 2021-03-20 16:34:26 +0000 UTC 87 | 2021-03-20 16:34:28 +0000 UTC 88 | 2021-03-20 16:34:30 +0000 UTC 89 | 2021-03-20 16:34:32 +0000 UTC 90 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 91 | 2021-03-20 16:34:34 +0000 UTC 92 | 2021-03-20 16:34:36 +0000 UTC 93 | 2021-03-20 16:34:38 +0000 UTC 94 | 2021-03-20 16:34:40 +0000 UTC 95 | 2021-03-20 16:34:42 +0000 UTC 96 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 97 | 2021-03-20 16:34:44 +0000 UTC 98 | 2021-03-20 16:34:46 +0000 UTC 99 | 2021-03-20 16:34:48 +0000 UTC 100 | 2021-03-20 16:34:50 +0000 UTC 101 | 2021-03-20 16:34:52 +0000 UTC 102 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 103 | 2021-03-20 16:34:54 +0000 UTC 104 | 2021-03-20 16:34:56 +0000 UTC 105 | 2021-03-20 16:34:58 +0000 UTC 106 | 2021-03-20 16:35:00 +0000 UTC 107 | -------------------------------------------------------------------------------- /part02/2.1/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | exercise_21: 5 | image: devopsdockeruh/simple-web-service:alpine 6 | volumes: 7 | - ./text.log:/usr/src/app/text.log 8 | container_name: ex21 9 | -------------------------------------------------------------------------------- /part02/2.1/text.log: -------------------------------------------------------------------------------- 1 | 2021-03-26 13:24:17 +0000 UTC 2 | 2021-03-26 13:24:19 +0000 UTC 3 | 2021-03-26 13:24:21 +0000 UTC 4 | 2021-03-26 13:24:23 +0000 UTC 5 | 2021-03-26 13:24:25 +0000 UTC 6 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 7 | 2021-03-26 13:24:27 +0000 UTC 8 | 2021-03-26 13:24:29 +0000 UTC 9 | 2021-03-26 13:24:31 +0000 UTC 10 | 2021-03-26 13:24:33 +0000 UTC 11 | 2021-03-26 13:24:35 +0000 UTC 12 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 13 | 2021-03-26 13:24:37 +0000 UTC 14 | 2021-03-26 13:24:39 +0000 UTC 15 | 2021-03-26 13:24:41 +0000 UTC 16 | 2021-03-26 13:24:43 +0000 UTC 17 | 2021-03-26 13:24:45 +0000 UTC 18 | Secret message is: 'You can find the source code here: https://github.com/docker-hy' 19 | 2021-03-26 13:24:47 +0000 UTC 20 | 2021-03-26 13:24:49 +0000 UTC 21 | 2021-03-26 13:24:51 +0000 UTC 22 | -------------------------------------------------------------------------------- /part02/2.10/backend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.15 2 | 3 | WORKDIR /usr/src/app 4 | 5 | EXPOSE 8080 6 | 7 | COPY . . 8 | 9 | RUN go build 10 | ENV REQUEST_ORIGIN=http://localhost 11 | 12 | CMD ./server 13 | -------------------------------------------------------------------------------- /part02/2.10/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | frontend_server: 5 | image: frontend 6 | build: ./example-frontend 7 | ports: 8 | - 5000:5000 9 | container_name: frontend 10 | 11 | backend_server: 12 | image: backend 13 | build: ./example-backend 14 | ports: 15 | - 8080:8080 16 | environment: 17 | - REDIS_HOST=redis_server 18 | - POSTGRES_HOST=postgres_server 19 | - POSTGRES_USER=postgres 20 | - POSTGRES_PASSWORD=postgres 21 | - POSTGRES_DATABASE=postgres 22 | 23 | container_name: backend 24 | depends_on: 25 | - postgres_server 26 | - redis_server 27 | 28 | redis_server: 29 | image: redis 30 | restart: unless-stopped 31 | container_name: redis 32 | 33 | postgres_server: 34 | image: postgres:13.2-alpine 35 | restart: unless-stopped 36 | environment: 37 | POSTGRES_PASSWORD: postgres 38 | container_name: postgres 39 | volumes: 40 | - database:/var/lib/postgresql/data 41 | 42 | reverse_proxy: 43 | image: nginx:1.19-alpine 44 | restart: unless-stopped 45 | volumes: 46 | - ./nginx.conf:/etc/nginx/nginx.conf 47 | ports: 48 | - 80:80 49 | environment: 50 | - NGINX_PORT=80 51 | 52 | volumes: 53 | database: 54 | 55 | -------------------------------------------------------------------------------- /part02/2.10/ex_2_10_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part02/2.10/ex_2_10_screenshot.png -------------------------------------------------------------------------------- /part02/2.10/explanation.txt: -------------------------------------------------------------------------------- 1 | Problem: The issue was with CORS setup. 2 | 3 | Steps Taken: 4 | 5 | 01. Change the Dockerfile for Backend; 6 | Set ENV 'REQUEST_ORIGIN=http://localhost' instead of 'ENV REQUEST_ORIGIN=http://localhost:5000' 7 | 02. Make sure to new build for backend image. 8 | -------------------------------------------------------------------------------- /part02/2.10/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | events { worker_connections 1024; } 3 | 4 | http { 5 | server { 6 | listen 80; 7 | 8 | location / { 9 | proxy_pass http://frontend_server:5000/; 10 | } 11 | 12 | location /api/ { 13 | proxy_set_header Host $host; 14 | proxy_pass http://backend_server:8080/; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /part02/2.11/flask-dev-env/.gitignore: -------------------------------------------------------------------------------- 1 | env/ 2 | __pycache__/ 3 | -------------------------------------------------------------------------------- /part02/2.11/flask-dev-env/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8-slim 2 | 3 | WORKDIR /app 4 | 5 | COPY . . 6 | 7 | RUN pip install -r requirements.txt 8 | 9 | 10 | EXPOSE 5000 11 | -------------------------------------------------------------------------------- /part02/2.11/flask-dev-env/README.md: -------------------------------------------------------------------------------- 1 | # github-actions-ci-cd-pipeline -------------------------------------------------------------------------------- /part02/2.11/flask-dev-env/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | app: 5 | build: . 6 | image: flask-dev-env 7 | command: python src/app.py 8 | ports: 9 | - 5000:5000 10 | volumes: 11 | - .:/app 12 | container_name: flask-dev-env 13 | -------------------------------------------------------------------------------- /part02/2.11/flask-dev-env/requirements.txt: -------------------------------------------------------------------------------- 1 | attrs==21.2.0 2 | click==8.0.1 3 | Flask==2.0.1 4 | iniconfig==1.1.1 5 | itsdangerous==2.0.1 6 | Jinja2==3.0.1 7 | MarkupSafe==2.0.1 8 | packaging==20.9 9 | pluggy==0.13.1 10 | py==1.10.0 11 | pyparsing==2.4.7 12 | pytest==6.2.4 13 | toml==0.10.2 14 | Werkzeug==2.0.1 15 | -------------------------------------------------------------------------------- /part02/2.11/flask-dev-env/src/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | 3 | app = Flask(__name__) 4 | 5 | @app.route("/") 6 | def index(): 7 | return "Hello, world!" 8 | 9 | @app.route("/change") 10 | def change(): 11 | return "Change" 12 | 13 | 14 | if __name__ == "__main__": 15 | app.run(host="0.0.0.0", debug=True) -------------------------------------------------------------------------------- /part02/2.11/work.md: -------------------------------------------------------------------------------- 1 | - I created a simple flask app. 2 | - Created a Dockerfile to make a image of my app. 3 | - Created a docker-compose file which is mantain my docker+app developement environment. 4 | - Properly placed 'volumes', so that my changes will effect correctly in docker environment. 5 | 6 | ## _docker-compose.yml_ 7 | 8 | ``` 9 | version: "3.5" 10 | 11 | services: 12 | app: 13 | build: . 14 | image: flask-dev-env 15 | command: python src/app.py 16 | ports: 17 | - 5000:5000 18 | volumes: 19 | - .:/app 20 | container_name: flask-dev-env 21 | ``` 22 | -------------------------------------------------------------------------------- /part02/2.2/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | simple-web-server: 5 | image: devopsdockeruh/simple-web-service:alpine 6 | ports: 7 | - 8000:8080 8 | 9 | command: server 10 | 11 | container_name: web-server 12 | -------------------------------------------------------------------------------- /part02/2.3/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | frontend_server: 5 | image: frontend 6 | ports: 7 | - 5000:5000 8 | container_name: frontend 9 | 10 | backend_server: 11 | image: backend 12 | ports: 13 | - 8080:8080 14 | container_name: backend 15 | -------------------------------------------------------------------------------- /part02/2.4/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | frontend_server: 5 | image: frontend 6 | ports: 7 | - 5000:5000 8 | container_name: frontend 9 | 10 | backend_server: 11 | image: backend 12 | ports: 13 | - 8080:8080 14 | container_name: backend 15 | environment: 16 | - REDIS_HOST=redis_server 17 | 18 | redis_server: 19 | image: redis 20 | container_name: redis_server 21 | -------------------------------------------------------------------------------- /part02/2.5/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.2" 2 | services: 3 | calculator: 4 | image: devopsdockeruh/scaling-exercise-calculator 5 | ports: 6 | - 3000:3000 7 | container_name: calculator 8 | compute: 9 | image: devopsdockeruh/scaling-exercise-compute 10 | environment: 11 | - VIRTUAL_HOST=compute.localtest.me 12 | load-balancer: 13 | build: ./load-balancer 14 | image: load-balancer 15 | volumes: 16 | - /var/run/docker.sock:/tmp/docker.sock:ro 17 | ports: 18 | - 80:80 19 | container_name: load-balancer 20 | -------------------------------------------------------------------------------- /part02/2.5/ex2.5_commands.md: -------------------------------------------------------------------------------- 1 | 2 | ```console 3 | ~/Code/devops-with-docker/part02/2.5 $ docker-compose up -d --scale compute=10 4 | load-balancer is up-to-date 5 | Recreating calculator ... done 6 | Creating scaling-exercise_compute_3 ... done 7 | Creating scaling-exercise_compute_4 ... done 8 | Creating scaling-exercise_compute_5 ... done 9 | Creating scaling-exercise_compute_6 ... done 10 | Creating scaling-exercise_compute_7 ... done 11 | Creating scaling-exercise_compute_8 ... done 12 | Creating scaling-exercise_compute_9 ... done 13 | Creating scaling-exercise_compute_10 ... done 14 | ~/Code/devops-with-docker/part02/2.5 $ docker-compose ps 15 | Name Command State Ports 16 | --------------------------------------------------------------------------------------------------------------- 17 | calculator docker-entrypoint.sh npm start Up 0.0.0.0:3000->3000/tcp,:::3000->3000/tcp 18 | load-balancer /app/docker-entrypoint.sh ... Up 0.0.0.0:80->80/tcp,:::80->80/tcp 19 | scaling-exercise_compute_1 docker-entrypoint.sh node ... Up 3000/tcp 20 | scaling-exercise_compute_10 docker-entrypoint.sh node ... Up 3000/tcp 21 | scaling-exercise_compute_2 docker-entrypoint.sh node ... Up 3000/tcp 22 | scaling-exercise_compute_3 docker-entrypoint.sh node ... Up 3000/tcp 23 | scaling-exercise_compute_4 docker-entrypoint.sh node ... Up 3000/tcp 24 | scaling-exercise_compute_5 docker-entrypoint.sh node ... Up 3000/tcp 25 | scaling-exercise_compute_6 docker-entrypoint.sh node ... Up 3000/tcp 26 | scaling-exercise_compute_7 docker-entrypoint.sh node ... Up 3000/tcp 27 | scaling-exercise_compute_8 docker-entrypoint.sh node ... Up 3000/tcp 28 | scaling-exercise_compute_9 docker-entrypoint.sh node ... Up 3000/tcp 29 | ``` 30 | 31 | 32 | -------------------------------------------------------------------------------- /part02/2.5/ex2_5_screenshot_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part02/2.5/ex2_5_screenshot_01.png -------------------------------------------------------------------------------- /part02/2.5/ex2_5_screenshot_02png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part02/2.5/ex2_5_screenshot_02png -------------------------------------------------------------------------------- /part02/2.6/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | frontend_server: 5 | image: frontend-test 6 | build: ./example-frontend 7 | ports: 8 | - 5000:5000 9 | container_name: frontend 10 | 11 | backend_server: 12 | image: backend-test 13 | build: ./example-backend 14 | ports: 15 | - 8080:8080 16 | environment: 17 | - REDIS_HOST=redis_server 18 | - POSTGRES_HOST=postgres_server 19 | - POSTGRES_USER=postgres 20 | - POSTGRES_PASSWORD=postgres 21 | - POSTGRES_DATABASE=postgres 22 | 23 | container_name: backend 24 | depends_on: 25 | - postgres_server 26 | - redis_server 27 | 28 | redis_server: 29 | image: redis 30 | restart: unless-stopped 31 | container_name: redis 32 | 33 | postgres_server: 34 | image: postgres:13.2-alpine 35 | restart: unless-stopped 36 | environment: 37 | POSTGRES_PASSWORD: postgres 38 | container_name: postgres 39 | 40 | -------------------------------------------------------------------------------- /part02/2.7/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | frontend: 5 | image: frontend-ml 6 | build: ./ml-kurkkumopo-frontend 7 | ports: 8 | - 3000:3000 9 | container_name: frontend-ml 10 | 11 | backend: 12 | image: backend-ml 13 | build: ./ml-kurkkumopo-backend 14 | ports: 15 | - 5000:5000 16 | volumes: 17 | - models:/src/model 18 | container_name: backend-ml 19 | depends_on: 20 | - training 21 | 22 | training: 23 | image: training-ml 24 | build: ./ml-kurkkumopo-training 25 | volumes: 26 | - models:/src/model 27 | - imgs:/src/imgs 28 | 29 | volumes: 30 | imgs: 31 | models: 32 | -------------------------------------------------------------------------------- /part02/2.7/ex_2_7_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part02/2.7/ex_2_7_screenshot.png -------------------------------------------------------------------------------- /part02/2.8/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | frontend_server: 5 | image: frontend 6 | build: ./example-frontend 7 | ports: 8 | - 5000:5000 9 | container_name: frontend 10 | 11 | backend_server: 12 | image: backend 13 | build: ./example-backend 14 | ports: 15 | - 8080:8080 16 | environment: 17 | - REDIS_HOST=redis_server 18 | - POSTGRES_HOST=postgres_server 19 | - POSTGRES_USER=postgres 20 | - POSTGRES_PASSWORD=postgres 21 | - POSTGRES_DATABASE=postgres 22 | 23 | container_name: backend 24 | depends_on: 25 | - postgres_server 26 | - redis_server 27 | 28 | redis_server: 29 | image: redis 30 | restart: unless-stopped 31 | container_name: redis 32 | 33 | postgres_server: 34 | image: postgres:13.2-alpine 35 | restart: unless-stopped 36 | environment: 37 | POSTGRES_PASSWORD: postgres 38 | container_name: postgres 39 | 40 | reverse_proxy: 41 | image: nginx:1.19-alpine 42 | restart: unless-stopped 43 | volumes: 44 | - ./nginx.conf:/etc/nginx/nginx.conf 45 | ports: 46 | - 80:80 47 | environment: 48 | - NGINX_PORT=80 49 | -------------------------------------------------------------------------------- /part02/2.8/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | events { worker_connections 1024; } 3 | 4 | http { 5 | server { 6 | listen 80; 7 | 8 | location / { 9 | proxy_pass http://frontend_server:5000/; 10 | } 11 | 12 | location /api/ { 13 | proxy_set_header Host $host; 14 | proxy_pass http://backend_server:8080/; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /part02/2.9/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | frontend_server: 5 | image: frontend 6 | build: ./example-frontend 7 | ports: 8 | - 5000:5000 9 | container_name: frontend 10 | 11 | backend_server: 12 | image: backend 13 | build: ./example-backend 14 | ports: 15 | - 8080:8080 16 | environment: 17 | - REDIS_HOST=redis_server 18 | - POSTGRES_HOST=postgres_server 19 | - POSTGRES_USER=postgres 20 | - POSTGRES_PASSWORD=postgres 21 | - POSTGRES_DATABASE=postgres 22 | 23 | container_name: backend 24 | depends_on: 25 | - postgres_server 26 | - redis_server 27 | 28 | redis_server: 29 | image: redis 30 | restart: unless-stopped 31 | container_name: redis 32 | 33 | postgres_server: 34 | image: postgres:13.2-alpine 35 | restart: unless-stopped 36 | environment: 37 | POSTGRES_PASSWORD: postgres 38 | container_name: postgres 39 | volumes: 40 | - database:/var/lib/postgresql/data 41 | 42 | reverse_proxy: 43 | image: nginx:1.19-alpine 44 | restart: unless-stopped 45 | volumes: 46 | - ./nginx.conf:/etc/nginx/nginx.conf 47 | ports: 48 | - 80:80 49 | environment: 50 | - NGINX_PORT=80 51 | 52 | volumes: 53 | database: 54 | -------------------------------------------------------------------------------- /part02/2.9/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | events { worker_connections 1024; } 3 | 4 | http { 5 | server { 6 | listen 80; 7 | 8 | location / { 9 | proxy_pass http://frontend_server:5000/; 10 | } 11 | 12 | location /api/ { 13 | proxy_set_header Host $host; 14 | proxy_pass http://backend_server:8080/; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /part03/3.1/build.yml: -------------------------------------------------------------------------------- 1 | name: Release DevOps with Docker 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | 14 | - name: Login to DockerHub 15 | uses: docker/login-action@v1 16 | with: 17 | username: ${{ secrets.DOCKERHUB_USERNAME }} 18 | password: ${{ secrets.DOCKERHUB_TOKEN }} 19 | 20 | - name: Build and push 21 | uses: docker/build-push-action@v2 22 | with: 23 | push: true 24 | tags: faysalmehedi/dwd-coursepage:latest 25 | 26 | - name: Deploy on heroku 27 | uses: akhileshns/heroku-deploy@v3.12.12 28 | with: 29 | heroku_api_key: ${{ secrets.HEROKU_API_KEY }} 30 | heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} 31 | heroku_email: ${{ secrets.HEROKU_EMAIL }} 32 | usedocker: true 33 | -------------------------------------------------------------------------------- /part03/3.1/ex_3_1_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part03/3.1/ex_3_1_screenshot.png -------------------------------------------------------------------------------- /part03/3.3/backend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.15 2 | 3 | WORKDIR /usr/src/app 4 | 5 | EXPOSE 8080 6 | 7 | COPY . . 8 | 9 | RUN go build 10 | ENV REQUEST_ORIGIN=http://localhost 11 | 12 | RUN useradd -m appuser 13 | RUN chown appuser . 14 | USER appuser 15 | 16 | CMD ./server -------------------------------------------------------------------------------- /part03/3.3/frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | WORKDIR /usr/src/app 4 | 5 | EXPOSE 5000 6 | 7 | 8 | RUN apt-get update 9 | RUN apt-get install -y curl 10 | 11 | RUN curl -sL https://deb.nodesource.com/setup_14.x | bash 12 | RUN apt install -y nodejs 13 | 14 | COPY . . 15 | 16 | RUN npm install 17 | RUN npm install -g serve 18 | 19 | ENV REACT_APP_BACKEND_URL=http://localhost:8080 20 | RUN npm run build 21 | 22 | RUN useradd -m appuser 23 | RUN chown appuser . 24 | 25 | USER appuser 26 | 27 | CMD [ "serve", "-s", "-l", "5000", "build" ] 28 | 29 | -------------------------------------------------------------------------------- /part03/3.4/backend/Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM golang:1.15 AS build-env 3 | 4 | WORKDIR /app 5 | 6 | COPY . . 7 | 8 | RUN go build 9 | 10 | FROM alpine 11 | 12 | WORKDIR /app 13 | EXPOSE 8080 14 | 15 | RUN apk update && apk add ca-certificates && \ 16 | rm -rf /var/cache/apk/* 17 | 18 | COPY --from=build-env /app /app 19 | 20 | RUN adduser -D appuser && \ 21 | chown appuser . 22 | 23 | USER appuser 24 | 25 | CMD ./server 26 | -------------------------------------------------------------------------------- /part03/3.4/ex_3_4_after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part03/3.4/ex_3_4_after.png -------------------------------------------------------------------------------- /part03/3.4/ex_3_4_before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part03/3.4/ex_3_4_before.png -------------------------------------------------------------------------------- /part03/3.4/frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:18.04 2 | 3 | WORKDIR /usr/src/app 4 | 5 | EXPOSE 5000 6 | 7 | COPY . . 8 | 9 | ENV REACT_APP_BACKEND_URL=http://localhost:8080 10 | 11 | RUN apt-get update && \ 12 | apt-get install -y curl && \ 13 | curl -sL https://deb.nodesource.com/setup_14.x | bash && \ 14 | apt install -y nodejs && \ 15 | npm install && \ 16 | npm install -g serve && \ 17 | npm run build && \ 18 | rm -rf /var/lib/apt/lists/* && \ 19 | useradd -m appuser && \ 20 | chown appuser . 21 | 22 | 23 | USER appuser 24 | 25 | CMD [ "serve", "-s", "-l", "5000", "build" ] 26 | 27 | 28 | -------------------------------------------------------------------------------- /part03/3.5/backend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.15 AS build-env 2 | 3 | WORKDIR /usr/src/app 4 | 5 | COPY . . 6 | ENV CGO_ENABLED=0 7 | 8 | RUN go build 9 | 10 | FROM alpine 11 | 12 | WORKDIR /usr/src/app 13 | 14 | EXPOSE 8080 15 | ENV REQUEST_ORIGIN=http://localhost 16 | 17 | COPY --from=build-env /usr/src/app /usr/src/app 18 | 19 | RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* && \ 20 | adduser -D appuser && \ 21 | # chown appuser . 22 | chmod +x server 23 | 24 | USER appuser 25 | 26 | CMD ./server 27 | -------------------------------------------------------------------------------- /part03/3.5/ex_3_5_after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part03/3.5/ex_3_5_after.png -------------------------------------------------------------------------------- /part03/3.5/ex_3_5_before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part03/3.5/ex_3_5_before.png -------------------------------------------------------------------------------- /part03/3.5/frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | 3 | WORKDIR /usr/src/app 4 | 5 | EXPOSE 5000 6 | 7 | COPY . . 8 | 9 | ENV REACT_APP_BACKEND_URL=http://localhost:8080 10 | 11 | RUN apk update && apk add --no-cache curl npm bash nodejs && \ 12 | curl -sL https://deb.nodesource.com/setup_14.x && \ 13 | npm install && \ 14 | npm install -g serve && \ 15 | npm run build && \ 16 | apk del curl && \ 17 | rm -rf /var/lib/apt/lists/* && \ 18 | adduser -D appuser && \ 19 | chown appuser . 20 | 21 | USER appuser 22 | 23 | CMD [ "serve", "-s", "-l", "5000", "build" ] -------------------------------------------------------------------------------- /part03/3.6/backend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.16 AS build-env 2 | 3 | WORKDIR /usr/src/app 4 | 5 | COPY . . 6 | 7 | ENV CGO_ENABLED=0 8 | RUN go build && \ 9 | useradd -m appuser && \ 10 | chown appuser server 11 | 12 | FROM scratch 13 | 14 | EXPOSE 8080 15 | 16 | WORKDIR /usr/src/app 17 | 18 | COPY --from=build-env /usr/src/app/server /usr/src/app 19 | COPY --from=build-env /etc/passwd /etc/passwd 20 | 21 | USER appuser 22 | 23 | ENTRYPOINT [ "./server" ] -------------------------------------------------------------------------------- /part03/3.6/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.5" 2 | 3 | services: 4 | frontend_server: 5 | image: frontend 6 | build: ./example-frontend 7 | ports: 8 | - 5000:5000 9 | environment: 10 | - REACT_APP_BACKEND_URL=http://localhost:8080 11 | container_name: frontend 12 | 13 | backend_server: 14 | image: backend 15 | build: ./example-backend 16 | ports: 17 | - 8080:8080 18 | environment: 19 | - REDIS_HOST=redis_server 20 | - POSTGRES_HOST=postgres_server 21 | - POSTGRES_USER=postgres 22 | - POSTGRES_PASSWORD=postgres 23 | - POSTGRES_DATABASE=postgres 24 | - REQUEST_ORIGIN=http://localhost 25 | 26 | container_name: backend 27 | depends_on: 28 | - postgres_server 29 | - redis_server 30 | 31 | redis_server: 32 | image: redis 33 | restart: unless-stopped 34 | container_name: redis 35 | 36 | postgres_server: 37 | image: postgres:13.2-alpine 38 | restart: unless-stopped 39 | environment: 40 | POSTGRES_PASSWORD: postgres 41 | container_name: postgres 42 | volumes: 43 | - database:/var/lib/postgresql/data 44 | 45 | reverse_proxy: 46 | image: nginx:1.19-alpine 47 | restart: unless-stopped 48 | volumes: 49 | - ./nginx.conf:/etc/nginx/nginx.conf 50 | ports: 51 | - 80:80 52 | environment: 53 | - NGINX_PORT=80 54 | 55 | volumes: 56 | database: 57 | -------------------------------------------------------------------------------- /part03/3.6/ex_3_6_after.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part03/3.6/ex_3_6_after.png -------------------------------------------------------------------------------- /part03/3.6/ex_3_6_before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part03/3.6/ex_3_6_before.png -------------------------------------------------------------------------------- /part03/3.6/frontend/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:14 AS build-phase 2 | 3 | WORKDIR /usr/src/app 4 | 5 | COPY . . 6 | 7 | RUN npm install -g serve && \ 8 | npm install && \ 9 | npm run build 10 | 11 | FROM node:14-alpine3.13 12 | 13 | EXPOSE 5000 14 | 15 | WORKDIR /usr/src/app 16 | 17 | COPY --from=build-phase /usr/src/app/build/ /usr/src/app/build 18 | 19 | RUN npm install -g serve && \ 20 | adduser -D appuser && \ 21 | chown appuser build 22 | 23 | USER appuser 24 | 25 | ENTRYPOINT [ "serve", "-s", "-l", "5000", "build" ] 26 | 27 | -------------------------------------------------------------------------------- /part03/3.7/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8 AS build-phase 2 | 3 | WORKDIR /usr/src/app 4 | COPY . . 5 | 6 | RUN ./mvnw package 7 | 8 | FROM openjdk:alpine 9 | 10 | EXPOSE 8080 11 | WORKDIR /usr/src/app 12 | COPY --from=build-phase /usr/src/app//target/docker-example-1.1.3.jar /usr/src/app//target/docker-example-1.1.3.jar 13 | 14 | RUN adduser -D user01 15 | USER user01 16 | 17 | CMD ["java", "-jar", "./target/docker-example-1.1.3.jar"] 18 | 19 | -------------------------------------------------------------------------------- /part03/3.7/Dockerfile_without_optimized: -------------------------------------------------------------------------------- 1 | FROM openjdk:8 2 | 3 | EXPOSE 8080 4 | WORKDIR /usr/src/app 5 | 6 | COPY . . 7 | 8 | RUN ./mvnw package 9 | 10 | CMD ["java", "-jar", "./target/docker-example-1.1.3.jar"] 11 | 12 | -------------------------------------------------------------------------------- /part03/3.7/ex_3_7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part03/3.7/ex_3_7.PNG -------------------------------------------------------------------------------- /part03/3.8/kubernetes.drawio: -------------------------------------------------------------------------------- 1 | 7Vtbd5s4EP41fgyH++Uxdpzdnm13u+s9vb3JIGMajLwgx3Z/fSWQDAgIcmMa1k2OT4xGw0jM9400EvLEmG0Ov6Vgu36HAhhPdDU4TIy7ia67tkv+U8GxEJimWgjCNAoKkVYKFtE3yIRcbRcFMKspYoRiHG3rQh8lCfRxTQbSFO3raisU11vdghA2BAsfxE3pxyjAa/ZYllrKf4dRuOYtayqr2QCuzATZGgRoXxEZ84kxSxHCxdXmMIMx9R33S3HffUftqWMpTLDMDfNPX//468thPz18/fvL4r+P/8Kvxxv+HI8g3rEnZr3FR+6C/TrCcLEFPi3vCcoTY7rGm5iUNHIJsm3h+FV0gKStKbMIUwwPnX3VTh4gzIFoA3F6JCrsBsOzils4a3g/9yUGms1k66r/uRAw3MOT7dI15IJ55wxPac4oPWXzeGKeOgXOC3rKHqWnTG18nrJG6Sl9hJ4yR+mpETqq30/0iSMyw70FSxi/R1mEI5SQqiXCGG3qTuO6t3EUUh2MqFcBK/nETTAlggyn6AHOUIxI6S5BCWlquorimIsmuqGq0/m9TpXXYEu7sjmENGVQwLddCpUYbAvjWxRRq/NHYjxj3bgIVHWsjCZUTgtS1lBA6a9Adcz97riAMl6Bkks9XhooiSkie4DYp31T66AEIFvTOSGX5/NIVp9HBM/rrmPN9QZMpGaV/3Gn549oTclHVVSVzPYzVbEN+jWxiPYsr9BysS5IvVZpbkLU9DoMO/ndpL7FiCbIdFfQJZ8msR52S5gmkLhHiXxK8ek2fZNf3G1ARpn7fFpZ9dRfN+Vo5Q1FK4kc7ZVWg9EqQQG8REprqT/EKncoVkmskV5ZNXZWmQ1WWS/LKok9ildWjZ1VtjsyVnn9rKoQ6bTPqYqsaiS5Yi68iYKAWmwmtPlOrl58U7PUNQRuekm9ZlLzCSqJfYl1SA0ETW9OGC4HpoqCM9jKXmJpPwYYgiiFPlsAZWhHnXVpaDS9niO6TWz0lgAZbtNFYjH/i0Aj7rK+ODQSy/dfBBrbHlnUNOeVd5VFZAUg8sy4nq30bo8wkTxqbbvHKdolwYkBF4BArweH0TKpaEYLBsZQGPAO1MLDjnHOyEdyGdLLP0lic6MavIa0VKl8BxIQwg31wNXiZlujA64tG+gATm8Hbhqj8HohM4UcYQSQtWUJHZBp7ZC16L9FYZRw+TIVNcX7rxXuEQ6tzcxjMf/nw5vZ/IpR8HSlHnZay0Zb6+p1OBzcBg4fULzbwOuFQdyXsozmDoL7UzGQ2ZhiaXO0yY9k9b8z633rFtOKKfAfwtzDbVtUeWO3/GRAnueLxwRYf+7WGNMzZ7fUE/q9HyRavgG0igh2qeKTFslQCzAgX1SeUSW02e4IIW72KI0DItAoGXOtJcggWTe6yjYJL4G48HZ7BAemDIlFMcc8i5Iwhrd8gVRZC+1hhjvCpkKQFGHAbrjx8sMe1BQ/sKcquuc5qmqrhmlqGkkNbK7CDhyqiuG5umdYtuXarq275oXGQ8tSVK8+ILqaYjewMU/jZg0cQzGHQkdiXXzt6NieoTjWKNGReZd95eiY9mjRaWYUDXRgEjBI7vwYZFnki16vzvkwCOGC3YxSvEYhSkA8L6VT4rT0+Cl3t0W8wgSfqTVF1TwuuDtwi3npWC29h2lEHEDzk0qiQZt+GiHyXGiX+vAJj/DjeRikIcRPKTrtmKcwJiR8rPekDTh263v6amnSebjL1IVZrXgCdlcJf8PQabery1DxhA1DBGtwrKixV1/yHVbVJ/vl8Nm0XZ9cFD0oSX1y7jMO1DQ3hxYFExpsJyTK0zDKbJhF38AyrxLeMfI0OYYr3JLWnRK3wj470s9MTU4rvJ5R5YmQ7Rxr+LFJaRo+76CSRGZUGT+WMfIf8iAO7qOY+7Li1v7Ro8fxRT7dtgzpHx0u59OOiHQ9YUl5ynXPDu6GKUN8W3eh8O5u6fy+DRviEonGKxX5ybSOQftsIoqGhqJhVzvn9mtYCkochXpxCsJDhIvsq0i+SPEzb49cl2kXLdSyLpazVTO2Mj9rz9Zk+S6TmLExpTcxs9SJTAQdeZHv6Dx3dHeEkDJ/MKRMo8dQR0g1DN14dUM3hlM3hFarDNZsXCoSrP9DXlAhtXMWq8sQIktF+RgihSEXLs6448MRR2TxkJdsfNjC+xFTNDRgfJw7bdniq7ueaUvUN8VfworTnPak/jDTnCWx4Tam4B5kxvrp8WP2p/zSM0xzISL+lOVF5xhSLH9MXqiXv8g35t8B -------------------------------------------------------------------------------- /part03/3.8/kubernetes.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/faysalmehedi/devops-with-docker/6b89e7fb41b538ae0b6e3893c494809137c61213/part03/3.8/kubernetes.drawio.png --------------------------------------------------------------------------------