Skip to content

Commit

Permalink
Merge pull request #3 from Otus-DevOps-2023-05/docker-4
Browse files Browse the repository at this point in the history
Docker 4
  • Loading branch information
Baykanurov authored Nov 16, 2023
2 parents b485f0d + 885b00c commit ac6c858
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 5 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ yc compute instance create \
```shell
docker-machine --debug create \
--driver generic \
--generic-ip-address=51.250.84.88 \
--generic-ip-address=51.250.92.127 \
--generic-ssh-user yc-user \
--generic-ssh-key ~/.ssh/id_ed25519 \
docker-host
Expand Down Expand Up @@ -101,3 +101,18 @@ docker run -d --network=reddit --network-alias=post baykanurov/post:1.0
docker run -d --network=reddit --network-alias=comment baykanurov/comment:1.0
docker run -d --network=reddit -p 9292:9292 baykanurov/ui:1.0
```

## Docker-4
### Что было сделано:
- Изучено как работают сети Docker
- Написан docker-compose для сервисов нашего приложения
- Параметризированы значения в docker compose для:
- тегов образов для всех сервисов
- порт публикации сервиса ui
- username
- Также для всех параметров добавлены default values
- Задано имя для каждого контейнера
- Имя проекта можно задать через name в docker-compose
### Дополнительное задание
Добавил файл docker-compose.override.yml который пробрасывает код сервиса как volume и добавляет возможность запускать puma для руби приложений в дебаг
режиме с двумя воркерами
6 changes: 6 additions & 0 deletions src/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
USERNAME=test
MONGO_IMAGE_TAG=4.4
UI_IMAGE_TAG=1.0
POST_IMAGE_TAG=1.0
COMMENT_IMAGE_TAG=1.0
UI_PORT=9292
2 changes: 1 addition & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
docker-compose.yml
build_info.txt
prometheus/
.env

## python specific
*.pyc
2 changes: 1 addition & 1 deletion src/comment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ RUN apk update --no-cache && \
gem install bundler:1.17.2 && \
bundle install

ENTRYPOINT ["puma"]
CMD ["puma"]
49 changes: 49 additions & 0 deletions src/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
services:
mongo:
container_name: post_db
image: mongo:${MONGO_IMAGE_TAG:-4.4}
volumes:
- post_db:/data/db
networks:
- back_net
- front_net

ui:
container_name: ui
build: ./ui
image: ${USERNAME:-baykanurov}/ui:${UI_IMAGE_TAG:-1.0}
command: ["puma", "--debug", "-w 2"]
ports:
- ${UI_PORT:-9292}:9292/tcp
volumes:
- ./ui:/app:consistent
networks:
- front_net

post:
container_name: post
build: ./post-py
image: ${USERNAME:-baykanurov}/post:${POST_IMAGE_TAG:-1.0}
volumes:
- ./post-py:/app:consistent
networks:
- back_net
- front_net

comment:
container_name: comment
build: ./comment
image: ${USERNAME:-baykanurov}/comment:${COMMENT_IMAGE_TAG:-1.0}
command: ["puma", "--debug", "-w 2"]
volumes:
- ./comment:/app:consistent
networks:
- back_net
- front_net

volumes:
post_db:

networks:
back_net:
front_net:
41 changes: 41 additions & 0 deletions src/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.3'
services:
mongo:
container_name: post_db
image: mongo:${MONGO_IMAGE_TAG}
volumes:
- post_db:/data/db
networks:
- back_net

ui:
container_name: ui
build: ./ui
image: ${USERNAME}/ui:${UI_IMAGE_TAG}
ports:
- ${UI_PORT}:9292/tcp
networks:
- front_net

post:
container_name: post
build: ./post-py
image: ${USERNAME}/post:${POST_IMAGE_TAG}
networks:
- back_net
- front_net

comment:
container_name: comment
build: ./comment
image: ${USERNAME}/comment:${COMMENT_IMAGE_TAG}
networks:
- back_net
- front_net

volumes:
post_db:

networks:
back_net:
front_net:
2 changes: 1 addition & 1 deletion src/post-py/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ RUN apk --no-cache --update add build-base && \
pip install -r requirements.txt && \
apk del build-base

ENTRYPOINT ["python3", "post_app.py"]
CMD ["python3", "post_app.py"]
2 changes: 1 addition & 1 deletion src/ui/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ RUN apk update --no-cache && \
gem install bundler:1.17.2 && \
bundle install

ENTRYPOINT ["puma"]
CMD ["puma"]

0 comments on commit ac6c858

Please sign in to comment.