Blame view

docker/docker-compose.yml 5.64 KB
c49d7824   Alexis Koralewski   create new folder...
1
2
3
version: "3.9"

services:
e7016f79   Etienne Pallier   cleanup Dockerfil...
4
5
6
7

  #######################
  # MYSQL - DBMS
  #######################
c49d7824   Alexis Koralewski   create new folder...
8
9
  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
e4c37a1a   Alexis Koralewski   Upgrading mysql v...
10
    # This is fixed in pyros.py
e7016f79   Etienne Pallier   cleanup Dockerfil...
11
    container_name: pyros-db
e4c37a1a   Alexis Koralewski   Upgrading mysql v...
12
    image: mysql:8.0.28
c49d7824   Alexis Koralewski   create new folder...
13
    restart: always
e7016f79   Etienne Pallier   cleanup Dockerfil...
14
15
16
17
18
    command: --default-authentication-plugin=mysql_native_password
    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}"
      - VNC_NO_PASSWORD=1
787f04a2   Alexis Koralewski   Fix warning docke...
19
20
    env_file:
      - .env
e7016f79   Etienne Pallier   cleanup Dockerfil...
21
22
    volumes:
      - db:/var/lib/mysql/
23a61124   Alexis Koralewski   Change obsconfig ...
23
24
25
    deploy:  
      restart_policy:
        condition: on-failure
79e2cb01   Alexis Koralewski   fix docker warnings
26
        max_attempts: 5
23a61124   Alexis Koralewski   Change obsconfig ...
27
28
29
30
      resources:
          limits:
            cpus: '0.5'
            memory: 1GB
e7016f79   Etienne Pallier   cleanup Dockerfil...
31
            #pids: 1      
c49d7824   Alexis Koralewski   create new folder...
32
    # create network to allow images to communicate with other images within the same network 
23a61124   Alexis Koralewski   Change obsconfig ...
33
34
35
    # networks: 
    #   pyros-network: 
    #     ipv4_address: 172.19.0.2
1db8bdb9   Alexis Koralewski   removing mysql tc...
36
37
38
39
40
    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...
41

e7016f79   Etienne Pallier   cleanup Dockerfil...
42
43
44
  ######################################################
  # REDIS - in memory communication bus (for websockets)
  ######################################################
6f83043c   Alexis Koralewski   Add websocket for...
45
  redis:
e1d22a59   Alexis Koralewski   Change redis cont...
46
    container_name: pyros-redis
8e3c40f8   Alexis Koralewski   Add verion to pma...
47
    image: redis:7.0.7
6f83043c   Alexis Koralewski   Add websocket for...
48
    restart: always
e7016f79   Etienne Pallier   cleanup Dockerfil...
49
50
    ports:
      - "6379:6379"
23a61124   Alexis Koralewski   Change obsconfig ...
51
52
53
    deploy:  
      restart_policy:
        condition: on-failure
79e2cb01   Alexis Koralewski   fix docker warnings
54
        max_attempts: 5
23a61124   Alexis Koralewski   Change obsconfig ...
55
56
57
58
      resources:
          limits:
            cpus: '1'
            memory: 1GB
e7016f79   Etienne Pallier   cleanup Dockerfil...
59
            #pids: 1      
79e2cb01   Alexis Koralewski   fix docker warnings
60
61
62
63
64
    healthcheck:
      test: ["CMD", "redis-cli","ping"]
      timeout: 10s
      interval: 5s
      retries: 20
23a61124   Alexis Koralewski   Change obsconfig ...
65
66
67
    # networks: 
    #   pyros-network:  
    #     ipv4_address: 172.19.0.5
6f83043c   Alexis Koralewski   Add websocket for...
68

e7016f79   Etienne Pallier   cleanup Dockerfil...
69
70
71
72
73
  ######################################################
  # PYROS (main image : docker_pyros) => defined in Dockerfile
  # Ubuntu OS with Python3 and PyROS requirements installed
  # PyROS will later be installed on this image with "pyros.py install" (PYROS_DOCKER_INSTALL)
  ######################################################
49805654   Alexis Koralewski   renaming pyros co...
74
  pyros:
e7016f79   Etienne Pallier   cleanup Dockerfil...
75
76
    container_name: pyros
    restart: always    
23a61124   Alexis Koralewski   Change obsconfig ...
77
    #read_only: true
e045e5e0   Etienne Pallier   added comment
78
79
    # app/pyros is equivalent to your PYROS_SOFT/PYROS/ directory
    # Change "pyros" to whatever you want for the PYROS/ dir name (if you do not want "PYROS")
c6c12930   Alexis Koralewski   update docker-com...
80
81
    working_dir: 
      /home/pyros_user/app/pyros 
950ade71   Alexis Koralewski   fixing comment on...
82
    # path to the Dockerfile of this image
c49d7824   Alexis Koralewski   create new folder...
83
    environment:
23d1f666   Alexis Koralewski   Set specific envi...
84
85
      # environment variables only for Docker
      - WITH_DOCKER=y
e5d50896   Alexis Koralewski   Disabling common ...
86
87
88
      # disabling other env variables because they will override those from the env_file
      # - MYSQL_ROOT_LOGIN=root
      # - MYSQL_TCP_PORT=3306
23d1f666   Alexis Koralewski   Set specific envi...
89
      # environment variables available for both Docker usage and non Docker usage
e5d50896   Alexis Koralewski   Disabling common ...
90
91
92
      # - "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}"
      # - "MYSQL_PYROS_LOGIN=${MYSQL_PYROS_LOGIN:-pyros}"
      # - "MYSQL_PYROS_PWD=${MYSQL_PYROS_PWD:-DjangoPyros}"
48bacc35   Alexis Koralewski   add mysql port as...
93
      #- "IP_PYROS_USER=${IP_PYROS_USER:-172.28.1.5}"
d5436f46   Alexis Koralewski   Fix dockercompose...
94
95
    env_file: 
      - .env
e4c37a1a   Alexis Koralewski   Upgrading mysql v...
96
97
98
99
    build: 
      args:
        uid: ${CURRENT_UID}
      context: ..
acc4595e   Alexis Koralewski   Change path of Do...
100
      dockerfile: ./docker/Dockerfile
90bc3587   Alexis Koralewski   Add fix hostname ...
101
    hostname: ${COMPUTER_HOSTNAME}
e4c37a1a   Alexis Koralewski   Upgrading mysql v...
102
103
104
105
    # tty is the -t option in docker exec 
    tty: true
    # stdin_open is the -i option in docker exec
    stdin_open: true
c49d7824   Alexis Koralewski   create new folder...
106
    volumes:
9b2dff05   Alexis Koralewski   update dockerfile...
107
      - ../..:/home/pyros_user/app
c49d7824   Alexis Koralewski   create new folder...
108
109
    # 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...
110
      - "${PYROS_WEBSITE_PORT:-8000}:${PYROS_WEBSITE_PORT:-8000}"
d7a4c851   Etienne Pallier   Dockerfile avec U...
111
      - 5900:5900
c49d7824   Alexis Koralewski   create new folder...
112
113
114
    # starting db service before install service 
    depends_on:
      - db
6f83043c   Alexis Koralewski   Add websocket for...
115
      - redis
23a61124   Alexis Koralewski   Change obsconfig ...
116
117
118
    links:
      - db
      - redis
e7016f79   Etienne Pallier   cleanup Dockerfil...
119
120
121
122
123
124
125
126
127
    deploy:
      restart_policy:
        condition: on-failure
        max_attempts: 5
      resources:
        limits:
          cpus: '1'
          memory: 8GB
          #pids: 1      
c49d7824   Alexis Koralewski   create new folder...
128
    # create network to allow images to communicate with other images within the same network 
23a61124   Alexis Koralewski   Change obsconfig ...
129
130
131
    # networks: 
    #   pyros-network:
    #     ipv4_address: 172.19.0.3
48bacc35   Alexis Koralewski   add mysql port as...
132
        #ipv4_address: "${IP_PYROS_USER}"
79e2cb01   Alexis Koralewski   fix docker warnings
133
134
135
136
137
138
    healthcheck:
      test: ["CMD", "python3","-V"]
      timeout: 10s
      interval: 5s
      retries: 20

e7016f79   Etienne Pallier   cleanup Dockerfil...
139
140
141
142
  ######################################################
  # PHPMYADMIN (to interact manually with mysql db)
  # (dev only)
  ######################################################
864ec466   Alexis Koralewski   Renaming common t...
143
  phpmyadmin:
ec4214ff   Alexis Koralewski   Renaming pyros co...
144
    container_name: pyros-pma
8e3c40f8   Alexis Koralewski   Add verion to pma...
145
    image: phpmyadmin/phpmyadmin:5.2.0
e7016f79   Etienne Pallier   cleanup Dockerfil...
146
    restart: always    
864ec466   Alexis Koralewski   Renaming common t...
147
148
149
150
151
152
    links:
      - db
    environment:
      PMA_HOST: db
      PMA_PORT: 3306
      PMA_ARBITRARY: 1
e7016f79   Etienne Pallier   cleanup Dockerfil...
153
154
155
156
157
158
159
    env_file: 
      - .env
    # networks: 
    #   pyros-network:
    #     ipv4_address: 172.19.0.4
    ports:
      - "${PHPMYADMIN_PORT:-8081}:80"
79e2cb01   Alexis Koralewski   fix docker warnings
160
161
162
163
164
165
166
167
168
    deploy:  
      restart_policy:
        condition: on-failure
        max_attempts: 5
      resources:
          limits:
            cpus: '1'
            memory: 1GB
            #pids: 1
79e2cb01   Alexis Koralewski   fix docker warnings
169
170
171
172
173
    healthcheck:
      test: ["CMD", 'mysqladmin', 'ping', '-h', 'db', '-u', 'root', '-p$$MYSQL_ROOT_PASSWORD' ]
      timeout: 10s
      interval: 5s
      retries: 20
1db8bdb9   Alexis Koralewski   removing mysql tc...
174

6f83043c   Alexis Koralewski   Add websocket for...
175

e7016f79   Etienne Pallier   cleanup Dockerfil...
176
177
178
######################################################
# Declaring volumes
######################################################
c49d7824   Alexis Koralewski   create new folder...
179
180
181
volumes:
  db:
    driver: local
e7016f79   Etienne Pallier   cleanup Dockerfil...
182
183
184
185

######################################################
# Declaring networks
######################################################
23a61124   Alexis Koralewski   Change obsconfig ...
186
187
188
189
190
191
192
193
# networks: 
#   pyros-network:
#     #bridge is the default network driver
#     driver: bridge
#     ipam:
#       config:
#         - subnet: 172.19.0.0/16
#           gateway: 172.19.0.1