Blame view

docker/docker-compose.yml 3.55 KB
c49d7824   Alexis Koralewski   create new folder...
1
2
3
4
5
6
7
8
9
10
11
12
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}"
c49d7824   Alexis Koralewski   create new folder...
13
14
    volumes:
      - db:/var/lib/mysql/
c49d7824   Alexis Koralewski   create new folder...
15
16
    # create network to allow images to communicate with other images within the same network 
    networks: 
950ade71   Alexis Koralewski   fixing comment on...
17
      - pyros-network
1db8bdb9   Alexis Koralewski   removing mysql tc...
18
19
20
21
22
    healthcheck:
      test: ["CMD", 'mysqladmin', 'ping', '-h', 'db', '-u', 'root', '-p$$MYSQL_ROOT_PASSWORD' ]
      timeout: 10s
      interval: 5s
      retries: 20
c49d7824   Alexis Koralewski   create new folder...
23
24

  # service image of python, that let users to interact with python scripts such as pyros.
49805654   Alexis Koralewski   renaming pyros co...
25
  pyros:
950ade71   Alexis Koralewski   fixing comment on...
26
    # path to the Dockerfile of this image
c49d7824   Alexis Koralewski   create new folder...
27
28
29
30
31
32
    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
426c1b7e   Alexis Koralewski   updating how envi...
33
34
    env_file: 
      - variables.env
c49d7824   Alexis Koralewski   create new folder...
35
    environment:
23d1f666   Alexis Koralewski   Set specific envi...
36
37
38
39
40
      # environment variables only for Docker
      - WITH_DOCKER=y
      - MYSQL_ROOT_LOGIN=root
      - MYSQL_TCP_PORT=3306
      # environment variables available for both Docker usage and non Docker usage
c49d7824   Alexis Koralewski   create new folder...
41
      - "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}"
8348453e   ALEXIS-PC\alexis   Updating environm...
42
43
      - "MYSQL_PYROS_LOGIN=${MYSQL_PYROS_LOGIN:-pyros}"
      - "MYSQL_PYROS_PWD=${MYSQL_PYROS_PWD:-DjangoPyros}"
48bacc35   Alexis Koralewski   add mysql port as...
44
      #- "IP_PYROS_USER=${IP_PYROS_USER:-172.28.1.5}"
c49d7824   Alexis Koralewski   create new folder...
45
    volumes:
9cddcbc7   Alexis Koralewski   fixing path for p...
46
      - ..:/home/pyros_user/app
c49d7824   Alexis Koralewski   create new folder...
47
48
    # tells which port of local machine can communicate with the docker image (host:container), host is your local machine
    ports:
3e125e8f   Alexis Koralewski   Add webport perso...
49
      - "${PYROS_WEBSITE_PORT:-8000}:${PYROS_WEBSITE_PORT:-8000}"
c49d7824   Alexis Koralewski   create new folder...
50
51
52
53
54
    # starting db service before install service 
    depends_on:
      - db
    # create network to allow images to communicate with other images within the same network 
    networks: 
48bacc35   Alexis Koralewski   add mysql port as...
55
56
      - pyros-network
        #ipv4_address: "${IP_PYROS_USER}"
1db8bdb9   Alexis Koralewski   removing mysql tc...
57
58
    restart: always

53d41af0   Alexis Koralewski   Adding new servic...
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  pyros2:
    # path to the Dockerfile of this image
    build: 
      context: ..
      dockerfile: Dockerfile-django2
    container_name: pyros2
    # tty is the -t option in docker exec 
    tty: true
    # stdin_open is the -i option in docker exec
    stdin_open: true
    env_file: 
      - variables.env
    environment:
      # environment variables only for Docker
      - WITH_DOCKER=y
      - MYSQL_ROOT_LOGIN=root
      - MYSQL_TCP_PORT=3306
      # environment variables available for both Docker usage and non Docker usage
      - "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}"
      - "MYSQL_PYROS_LOGIN=${MYSQL_PYROS_LOGIN:-pyros}"
      - "MYSQL_PYROS_PWD=${MYSQL_PYROS_PWD:-DjangoPyros}"
      - PYROS_WEBSITE_PORT=8002
      #- "IP_PYROS_USER=${IP_PYROS_USER:-172.28.1.5}"
    volumes:
      - ..:/home/pyros_user/app
    # tells which port of local machine can communicate with the docker image (host:container), host is your local machine
    ports:
      - 8002:8002
    # 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
        #ipv4_address: "${IP_PYROS_USER}"
    restart: always

c49d7824   Alexis Koralewski   create new folder...
96
97
98
99
# declaring volumes
volumes:
  db:
    driver: local
c49d7824   Alexis Koralewski   create new folder...
100
101
102
# declaring networks
networks: 
  pyros-network:
c49d7824   Alexis Koralewski   create new folder...
103
    #bridge is the default network driver
1db8bdb9   Alexis Koralewski   removing mysql tc...
104
    driver: bridge