From 11987a49230cb3e11866a9593b347ee03684d8e4 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Wed, 20 Sep 2023 19:58:35 +0200 Subject: [PATCH] podman: don't use podman in podman but pass a socket By setting `CONTAINER_SOCK` prior to running `podman-compose up` the socket path is passed into the worker container and `CONTAINER_HOST` is automatically set. The workers then use `podman` to build images instead of running it *bare metal*. One should set `PUBLIC_PATH`, too, which points to the place where to store images and json files. Signed-off-by: Paul Spooren --- README.md | 7 ++++++- podman-compose.yml | 38 +++++++++++++++----------------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 6e48835b..22b64939 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,10 @@ Once Podman works, install `podman-compose`: Now it's possible to run all services via `podman-compose`: - mkdir -p ./asu-service/public/ + # where to store images and json files + export PUBLIC_PATH=$(pwd)/public + # absolute path to podman socket mounted into worker containers + export CONTAINER_SOCK=/run/user/1001/podman/podman.sock podman-compose up -d This will start the server, the Podman API container and two workers. The first @@ -105,6 +108,8 @@ the dependencies: #### Running a worker + # podman unix socket (not path), no need to mount anything + export CONTAINER_HOST=unix:///run/user/1001/podman/podman.sock poetry run rq worker ### API diff --git a/podman-compose.yml b/podman-compose.yml index fb3a192d..1989dd0d 100644 --- a/podman-compose.yml +++ b/podman-compose.yml @@ -1,60 +1,52 @@ version: "2" + volumes: - podman-sock: redis: + services: server: - image: "localhost/aparcar/asu:latest" + image: "asu:latest" build: context: ./ dockerfile: Containerfile environment: - REDIS_URL=redis://redis/ - volumes: - - "./asu-service/public/:/app/public/:rw" + - ALLOW_DEFAULTS + - PUBLIC_PATH ports: - "127.0.0.1:8000:8000" depends_on: - redis worker: - image: "localhost/aparcar/asu:latest" + image: "asu:latest" build: context: ./ dockerfile: Containerfile - command: rqworker --url "redis://redis" + command: rqworker environment: - - CONTAINER_HOST=unix:///tmp/socket/podman.sock + - CONTAINER_HOST=unix://$CONTAINER_SOCK - REDIS_URL=redis://redis/ volumes: - - ./asu-service/public/:/app/public/:rw - - podman-sock:/tmp/socket/:rw + - $PUBLIC_PATH:$PUBLIC_PATH:rw + - $CONTAINER_SOCK:$CONTAINER_SOCK:rw depends_on: - redis - - podman worker2: - image: "localhost/aparcar/asu:latest" + image: "asu:latest" build: context: ./ dockerfile: Containerfile - command: rqworker --url "redis://redis" + command: rqworker environment: - - CONTAINER_HOST=unix:///tmp/socket/podman.sock + - CONTAINER_HOST=unix://$CONTAINER_SOCK - REDIS_URL=redis://redis/ volumes: - - ./asu-service/public/:/app/public/:rw - - podman-sock:/tmp/socket/:rw + - $PUBLIC_PATH:$PUBLIC_PATH:rw + - $CONTAINER_SOCK:$CONTAINER_SOCK:rw depends_on: - redis - - podman - - podman: - image: quay.io/podman/stable - user: podman - volumes: - - podman-sock:/tmp/socket/ - command: sh -c "mkdir -p /tmp/socket && podman system service --time=0 unix:///tmp/socket/podman.sock" redis: image: "docker.io/redis:alpine"