Skip to content

Commit

Permalink
Add docker volume (#60)
Browse files Browse the repository at this point in the history
* Add docker volume

1. Add local docker volume through override docker-compose
2. Default no volume mount

* Add comment for cached mode

* 1. Use default mysql images mysql:8.0.22
2. Remove from Docker.env
3. Open changes for mysql image tag using `MYSQL_IMAGE_TAG` environment variable

* Update README

* add named volume

Co-authored-by: Raghav2211 <[email protected]>
  • Loading branch information
Raghav2211 and devraghv authored Dec 21, 2020
1 parent 94751cf commit 91e9726
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
3 changes: 3 additions & 0 deletions todo-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ docker build --build-arg JAR_FILE=build/libs/\*.jar --tag psi-todo:1.0.0 .
## Run ##
```bash
docker-compose --env-file=env/<env>/Docker.env up -d
#or
# Override default docker-compose configuration
docker-compose --env-file=env/<env>/Docker.env -f docker-compose.yaml -f env/<env>/docker-compose-override.yml up -d
```
2 changes: 1 addition & 1 deletion todo-app/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
psimysql:
image: ${MYSQL_IMAGE}
image: mysql:${MYSQL_IMAGE_TAG:-8.0.22}
container_name: mysql
ports:
- 3306:3306
Expand Down
1 change: 0 additions & 1 deletion todo-app/env/ci/Docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
PSI_TODO_IMAGE=psi-todo

#Database variables
MYSQL_IMAGE=mysql:8.0.22
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=psi
3 changes: 2 additions & 1 deletion todo-app/env/local/Docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ PSI_TODO_IMAGE=psi-todo:1.0.0
PSI_TODO_STACK_IMAGE=localhost:5000/psi-todo

#Database variables
MYSQL_IMAGE=mysql:8.0.22
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=psi
#MYSQL_DATA_SRC_PATH=
MYSQL_DATA_DEST_PATH=/var/lib/mysql
#BASIC_AUTH_ENABLE
# if BASIC_AUTH_ENABLE=true [Default is false] then set below two variables
#BASIC_AUTH_USERNAME=
Expand Down
23 changes: 12 additions & 11 deletions todo-app/env/local/docker-compose-override.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
version: "3"
services:
psimysql:
deploy:
placement:
constraints:
- "node.role == worker"
psitodoapp:
image: ${PSI_TODO_STACK_IMAGE}
deploy:
replicas: ${PSI_TODO_REPLICA}
placement:
constraints:
- "node.role == worker"
volumes:
- mysql_data:${MYSQL_DATA_DEST_PATH}:cached # Strong consistency is quite expensive, requiring coordination between all of a files writers to guarantee
# they don’t inappropriately clobber each other’s changes
# So Relax consistency guarantees using `cached` mode (Don’t do this in production …)
volumes:
mysql_data:
# To use below configuration for host path ensure MYSQL_DATA_SRC_PATH should exists
# driver: local
# driver_opts:
# type: none
# device: $PWD/${MYSQL_DATA_SRC_PATH}
# o: bind
14 changes: 14 additions & 0 deletions todo-app/env/local/docker-stack-compose-override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3"
services:
psimysql:
deploy:
placement:
constraints:
- "node.role == worker"
psitodoapp:
image: ${PSI_TODO_STACK_IMAGE}
deploy:
replicas: ${PSI_TODO_REPLICA}
placement:
constraints:
- "node.role == worker"

0 comments on commit 91e9726

Please sign in to comment.