Bind mount the pylib on docker container

I'm working with Ignition 8.1.37 with and dev env deploy on docker container with the /data directory bind monted. Now I need to also bind mount the pylib directory, how can this be done?

Pd.
Shoutout to @Kevin.Collins and all the other Docker/Ignition-savvy folks out there! Your expertise and dedication are much needed and highly appreciated in the community.

This is the yalm file tha we are using.

# Example shown in the session for bind-mount with init container via Docker Compose
---
services:
  init-gateway-active:
    container_name: ignition-active-init
    image: inductiveautomation/ignition:8.1.37
    entrypoint: sh -c
    volumes:
      # We mount this in the container as `/data` to not conflict with built-in files
      # at `/usr/local/bin/ignition/data`
      - ./gateway-data-active:/data
    networks:
      - network
    command:
      # Seed the files from the image to our /data if marker file not present, skip
      # if the marker file exists (and implicitly exit cleanly with status code 0)
      - |
        if [ ! -f /data/.ignition-seed-complete ]; then
          touch /data/.ignition-seed-complete ;
          cp -dpR /usr/local/bin/ignition/data/* /data/ ;
        fi
  gateway-active:
    container_name: ignition-dau-rd-mes
    image: inductiveautomation/ignition:8.1.37
    ports:
      - 8788:8088
      - 8743:8043
      - 8760:8060
      - 1890:1883
    volumes:
      - ./gateway-data-active:/usr/local/bin/ignition/data
    networks:
      - network  
    environment:
      GATEWAY_ADMIN_PASSWORD_FILE: /run/secrets/gateway-admin-password
      ACCEPT_IGNITION_EULA: "Y"
      IGNITION_EDITION: standard
      TZ: America/Bogota  # see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
    secrets:
      - gateway-admin-password
    # Use depends_on to only launch this container if our init container exits cleanly
    depends_on:
      init-gateway-active:
        condition: service_completed_successfully
    command: >
      -n gw-dau-rd-mes

  db:
    container_name: mysql-dau-rd-mes
    image: mysql:latest
    ports:
      - 3313:3306
    volumes:
      - mysql-data-active:/var/lib/mysql
    networks:
      - network
    environment:
      MYSQL_ROOT_PASSWORD_FILE: run/secrets/db-root-password
      MYSQL_DATABASE: plant 
      MYSQL_USER_FILE: run/secrets/db-user
      MYSQL_PASSWORD_FILE: run/secrets/db-user-password
    secrets:
      - db-root-password
      - db-user
      - db-user-password
      
secrets:
  gateway-admin-password:
    file: secrets/GATEWAY_ADMIN_PASSWORD_FILE
  db-root-password:
    file: secrets/DB_ROOT_PASSWORD_FILE
  db-user:
    file: secrets/DB_USER_FILE
  db-user-password:
    file: secrets/DB_USER_PASSWORD_FILE

volumes:
  mysql-data-active:
    name: mysql-dau-rd-mes

networks:
  network:
    name: deployment-dau-rd-mes

Hello @Ivan_H, I'm glad you're seeing some benefits here!

If you want to put third-party python libraries (external or your own), I'd recommend bind-mounting to /usr/local/bin/ignition/user-lib/pylib/site-packages folder, which is empty in a default installation (making it trivial for a bind-mount).

You can then drop modules/scripts in there such as shown below:

And then use those in a script, such as here:

2 Likes