crossbario / autobahn-python

WebSocket and WAMP in Python for Twisted and asyncio
https://crossbar.io/autobahn
MIT License
2.48k stars 770 forks source link

CI: auto-generate list of published Docker image references #1516

Open oberstet opened 2 years ago

oberstet commented 2 years ago

After building and uploading new Docker images for Autobahn, it would be great to have the new Docker images listed in a way that allows exact reference and direct use in other projects

Docker CLI and docker-compose allows to read env vars from a .env file, that if present, will make env vars already available during "docker-compose" phase (not only inside containers)

# Docker image references for Autobahn v21.1.1 (20220128-dc626948)
# https://hub.docker.com/r/crossbario/autobahn-python/tags?page=1&name=22.1.1

DOCKER_IMAGE_AUTOBAHN_PYTHON=crossbario/autobahn-python@sha256:dfed71b8441e219f2746ff08398d1571e99c666bf85bb4136fe2f9bf1a568650

Above can be computed like this

echo ${AUTOBAHN_VERSION}
echo ${AUTOBAHN_BUILD_ID}

docker inspect --format='{{index .RepoDigests 0}}' \
    crossbario/autobahn-python:cpy-amd64-${AUTOBAHN_VERSION}-${AUTOBAHN_BUILD_ID}
oberstet commented 2 years ago

So say you have 2 env files

Then you can use a docker-compose.yml like

    myapp:
        container_name: myapp
        image: ${DOCKER_IMAGE_AUTOBAHN_PYTHON}
        env_file:
            - myapp.env
        user: ${UID}:${GID}
        tty: true
        volumes:
            - "/home/ubuntu/myapp/:/app:rw"
        command:
            - python
            - myapp.py

The crucial point is: DOCKER_IMAGE_AUTOBAHN_PYTHON, UID and GID must be defined in .env.

Stuff in myapp.env is only available within myapp.py!

oberstet commented 2 years ago

see https://github.com/crossbario/autobahn-python/pull/1517