Blame view

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

4fac45d0   Etienne Pallier   petit bugfix de p...
3
# Application name (group name for the 4 images composing the PyROS app)
64fe9f0c   Alexis Koralewski   update docker-com...
4
name: pyros-app
63f2beb2   Etienne Pallier   renamed PYROS_DOC...
5

c49d7824   Alexis Koralewski   create new folder...
6
services:
e7016f79   Etienne Pallier   cleanup Dockerfil...
7
8
9
10

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

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

e7016f79   Etienne Pallier   cleanup Dockerfil...
72
73
74
75
76
  ######################################################
  # 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...
77
  pyros:
64fe9f0c   Alexis Koralewski   update docker-com...
78
79
80
81
    container_name: pyros-main
    restart: always 
    # For tnc only
    #image: pyros-user:1.0   
23a61124   Alexis Koralewski   Change obsconfig ...
82
    #read_only: true
e045e5e0   Etienne Pallier   added comment
83
84
    # 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...
85
86
    working_dir: 
      /home/pyros_user/app/pyros 
950ade71   Alexis Koralewski   fixing comment on...
87
    # path to the Dockerfile of this image
c49d7824   Alexis Koralewski   create new folder...
88
    environment:
23d1f666   Alexis Koralewski   Set specific envi...
89
90
      # environment variables only for Docker
      - WITH_DOCKER=y
e5d50896   Alexis Koralewski   Disabling common ...
91
92
93
      # 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...
94
      # environment variables available for both Docker usage and non Docker usage
e5d50896   Alexis Koralewski   Disabling common ...
95
96
97
      # - "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...
98
      #- "IP_PYROS_USER=${IP_PYROS_USER:-172.28.1.5}"
d5436f46   Alexis Koralewski   Fix dockercompose...
99
100
    env_file: 
      - .env
e4c37a1a   Alexis Koralewski   Upgrading mysql v...
101
102
103
104
    build: 
      args:
        uid: ${CURRENT_UID}
      context: ..
64fe9f0c   Alexis Koralewski   update docker-com...
105
106
      # For tnc only
      #dockerfile: ./docker/Dockerfile-pyros_user
acc4595e   Alexis Koralewski   Change path of Do...
107
      dockerfile: ./docker/Dockerfile
64fe9f0c   Alexis Koralewski   update docker-com...
108
109
      tags: 
        - "pyros-core:1.0"
90bc3587   Alexis Koralewski   Add fix hostname ...
110
    hostname: ${COMPUTER_HOSTNAME}
e4c37a1a   Alexis Koralewski   Upgrading mysql v...
111
112
113
114
    # tty is the -t option in docker exec 
    tty: true
    # stdin_open is the -i option in docker exec
    stdin_open: true
8ca1d24c   Etienne Pallier   quelques commenta...
115
    # Local PYROS_SOFT/ folder is linked to container /home/pyros_user/app folder
c49d7824   Alexis Koralewski   create new folder...
116
    volumes:
9b2dff05   Alexis Koralewski   update dockerfile...
117
      - ../..:/home/pyros_user/app
c49d7824   Alexis Koralewski   create new folder...
118
119
    # 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...
120
      - "${PYROS_WEBSITE_PORT:-8000}:${PYROS_WEBSITE_PORT:-8000}"
d7a4c851   Etienne Pallier   Dockerfile avec U...
121
      - 5900:5900
c49d7824   Alexis Koralewski   create new folder...
122
123
124
    # starting db service before install service 
    depends_on:
      - db
6f83043c   Alexis Koralewski   Add websocket for...
125
      - redis
23a61124   Alexis Koralewski   Change obsconfig ...
126
127
128
    links:
      - db
      - redis
e7016f79   Etienne Pallier   cleanup Dockerfil...
129
130
131
132
133
134
135
136
137
    deploy:
      restart_policy:
        condition: on-failure
        max_attempts: 5
      resources:
        limits:
          cpus: '1'
          memory: 8GB
          #pids: 1      
c49d7824   Alexis Koralewski   create new folder...
138
    # create network to allow images to communicate with other images within the same network 
23a61124   Alexis Koralewski   Change obsconfig ...
139
140
141
    # networks: 
    #   pyros-network:
    #     ipv4_address: 172.19.0.3
48bacc35   Alexis Koralewski   add mysql port as...
142
        #ipv4_address: "${IP_PYROS_USER}"
79e2cb01   Alexis Koralewski   fix docker warnings
143
144
145
146
147
148
    healthcheck:
      test: ["CMD", "python3","-V"]
      timeout: 10s
      interval: 5s
      retries: 20

e7016f79   Etienne Pallier   cleanup Dockerfil...
149
150
151
152
  ######################################################
  # PHPMYADMIN (to interact manually with mysql db)
  # (dev only)
  ######################################################
864ec466   Alexis Koralewski   Renaming common t...
153
  phpmyadmin:
ec4214ff   Alexis Koralewski   Renaming pyros co...
154
    container_name: pyros-pma
8e3c40f8   Alexis Koralewski   Add verion to pma...
155
    image: phpmyadmin/phpmyadmin:5.2.0
e7016f79   Etienne Pallier   cleanup Dockerfil...
156
    restart: always    
864ec466   Alexis Koralewski   Renaming common t...
157
158
159
160
161
162
    links:
      - db
    environment:
      PMA_HOST: db
      PMA_PORT: 3306
      PMA_ARBITRARY: 1
e7016f79   Etienne Pallier   cleanup Dockerfil...
163
164
165
166
167
168
169
    env_file: 
      - .env
    # networks: 
    #   pyros-network:
    #     ipv4_address: 172.19.0.4
    ports:
      - "${PHPMYADMIN_PORT:-8081}:80"
79e2cb01   Alexis Koralewski   fix docker warnings
170
171
172
173
174
175
176
177
178
    deploy:  
      restart_policy:
        condition: on-failure
        max_attempts: 5
      resources:
          limits:
            cpus: '1'
            memory: 1GB
            #pids: 1
79e2cb01   Alexis Koralewski   fix docker warnings
179
180
181
182
183
    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...
184

6f83043c   Alexis Koralewski   Add websocket for...
185

e7016f79   Etienne Pallier   cleanup Dockerfil...
186
187
188
######################################################
# Declaring volumes
######################################################
c49d7824   Alexis Koralewski   create new folder...
189
190
191
volumes:
  db:
    driver: local
e7016f79   Etienne Pallier   cleanup Dockerfil...
192
193
194
195

######################################################
# Declaring networks
######################################################
23a61124   Alexis Koralewski   Change obsconfig ...
196
197
198
199
200
201
202
203
# networks: 
#   pyros-network:
#     #bridge is the default network driver
#     driver: bridge
#     ipam:
#       config:
#         - subnet: 172.19.0.0/16
#           gateway: 172.19.0.1