Blame view

docker/docker-compose.yml 2.03 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}"
48bacc35   Alexis Koralewski   add mysql port as...
13
      - "MYSQL_TCP_PORT=${MYSQL_TCP_PORT:-3306}"
c49d7824   Alexis Koralewski   create new folder...
14
15
    volumes:
      - db:/var/lib/mysql/
c49d7824   Alexis Koralewski   create new folder...
16
17
    # create network to allow images to communicate with other images within the same network 
    networks: 
950ade71   Alexis Koralewski   fixing comment on...
18
      - pyros-network
c49d7824   Alexis Koralewski   create new folder...
19
20
21

  # service image of python, that let users to interact with python scripts such as pyros.
  install:
950ade71   Alexis Koralewski   fixing comment on...
22
    # path to the Dockerfile of this image
c49d7824   Alexis Koralewski   create new folder...
23
24
25
26
27
28
29
30
31
    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}"
48bacc35   Alexis Koralewski   add mysql port as...
32
33
      - "MYSQL_TCP_PORT=${MYSQL_TCP_PORT:-3306}"
      #- "IP_PYROS_USER=${IP_PYROS_USER:-172.28.1.5}"
c49d7824   Alexis Koralewski   create new folder...
34
    volumes:
9cddcbc7   Alexis Koralewski   fixing path for p...
35
      - ..:/home/pyros_user/app
c49d7824   Alexis Koralewski   create new folder...
36
37
38
39
40
41
42
43
    # 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: 
48bacc35   Alexis Koralewski   add mysql port as...
44
45
      - pyros-network
        #ipv4_address: "${IP_PYROS_USER}"
96a0355e   Alexis Koralewski   simplifying by re...
46
        
c49d7824   Alexis Koralewski   create new folder...
47
48
49
50
51
52
53
54
# declaring volumes
volumes:
  db:
    driver: local

# declaring networks
networks: 
  pyros-network:
c49d7824   Alexis Koralewski   create new folder...
55
56
    #bridge is the default network driver
    driver: bridge
96a0355e   Alexis Koralewski   simplifying by re...
57
58
59
60
61
62
    ipam:
      driver: default
      config:
        # we can define any ip adresses
        - subnet: 172.28.0.0/16
          gateway: 172.28.5.254