From c49d78249e69f2ed5d416a387101fabe6b10418d Mon Sep 17 00:00:00 2001 From: Alexis Koralewski Date: Wed, 10 Mar 2021 16:12:57 +0100 Subject: [PATCH] create new folder 'docker' which contains docker-compose.yml and .env-sample --- docker/.env-sample | 4 ++++ docker/docker-compose.yml | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 0 deletions(-) create mode 100644 docker/.env-sample create mode 100644 docker/docker-compose.yml diff --git a/docker/.env-sample b/docker/.env-sample new file mode 100644 index 0000000..993b8cb --- /dev/null +++ b/docker/.env-sample @@ -0,0 +1,4 @@ +# any value as password without any space +MYSQL_ROOT_PASSWORD=groot +# accepted values : y or yes +WITH_DOCKER=yes \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..95e6436 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,58 @@ +version: "3.9" + +services: + db: + # if we're using mysql >= 8, some of sql queries aren't valid anymore, like for creating and grant an user at the same time + image: mysql:5.7.22 + command: --default-authentication-plugin=mysql_native_password + restart: always + container_name: db_pyros + environment: + # note : as db is an image of mysql, this root password will be set on the first installation on the image, if the value is changed, it will not be updated in the database + - "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}" + volumes: + - db:/var/lib/mysql/ + - db:/var/lib/mysql-files + - ./mysql/:/etc/mysql/ + # create network to allow images to communicate with other images within the same network + networks: + pyros-network: + aliases: + - mysql + + # service image of python, that let users to interact with python scripts such as pyros. + install: + # build from the Dockerfile within the folder where docker-compose is saved + build: .. + container_name: pyros + # tty is the -t option in docker exec + tty: true + # stdin_open is the -i option in docker exec + stdin_open: true + environment: + - "WITH_DOCKER=${WITH_DOCKER:-y}" + - "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}" + volumes: + - .:/home/python/app + # tells which port of local machine can communicate with the docker image (host:container), host is your local machine + ports: + - "8000:8000" + # starting db service before install service + depends_on: + - db + # create network to allow images to communicate with other images within the same network + networks: + - pyros-network + +# declaring volumes +volumes: + db: + driver: local + +# declaring networks +networks: + pyros-network: + + #bridge is the default network driver + driver: bridge + \ No newline at end of file -- libgit2 0.21.2