Blame view

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

64fe9f0c   Alexis Koralewski   update docker-com...
3
name: pyros-app
63f2beb2   Etienne Pallier   renamed PYROS_DOC...
4

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

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

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

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

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

6f83043c   Alexis Koralewski   Add websocket for...
183

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

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