containers: Make config path configurable

Container configuration directory can be set in the .env file which is
automatically used by docker-compose.  The default value is the one used
previously (containers/config).
The HACKING.md guide is updated to describe how to set this and how it
affects other commands.
This commit is contained in:
Achilleas Koutsou 2021-01-15 16:24:59 +01:00 committed by Tom Gundersen
parent 4b1581a71c
commit 14183ba10a
3 changed files with 23 additions and 5 deletions

View file

@ -52,20 +52,37 @@ containers. Building and starting containers is generally faster than building
RPMs and installing them in a VM, so this method is more convenient for RPMs and installing them in a VM, so this method is more convenient for
developing and testing changes quickly. developing and testing changes quickly.
### Configuration
Each service (*composer* and *worker*) requires a configuration file and a set Each service (*composer* and *worker*) requires a configuration file and a set
of certificates. Use the [`tools/gen-certs.sh`](./tools/gen-certs.sh) script to of certificates. The storage location for these is shared between the
containers for simplicity. By default it's configured to be at
`./containers/config`, but this can be changed in the
[`./distribution/.env`](./distribution/.env) file by modifying the value of the
`$CONTAIN£R_CONFIG_DIR` variable (both absolute and relative paths work).
Use the [`tools/gen-certs.sh`](./tools/gen-certs.sh) script to
generate the certificates (using the test OpenSSL config file): generate the certificates (using the test OpenSSL config file):
./tools/gen-certs.sh ./test/data/x509/openssl.cnf ./containers/config ./containers/config/ca ./tools/gen-certs.sh ./test/data/x509/openssl.cnf ./containers/config ./containers/config/ca
The services also require a config file (each) which they expect to be in the Note that the two arguments `./containers/config` and `./containers/config/ca`
should be the same location as the `$CONTAINER_CONFIG_DIR` described above
The services also require a config file each which they expect to be in the
same directory. The following test files can be copied into it: same directory. The following test files can be copied into it:
cp ./test/data/composer/osbuild-composer.toml ./test/data/composer/osbuild-worker.toml ./containers/config/ cp ./test/data/composer/osbuild-composer.toml ./test/data/composer/osbuild-worker.toml ./containers/config/
The `containers/config` directory will be mounted inside both containers (see The `$CONTAINER_CONFIG_DIR` (default `containers/config`) directory will be mounted inside both containers (see
the [`docker-composer.yml`](./distribution/docker-compose.yml) file). the [`docker-composer.yml`](./distribution/docker-compose.yml) file).
### Build and run
To build the containers, change into the `distribution/` directory and run:
docker-compose build
To start the containers, change into the `distribution/` directory and run: To start the containers, change into the `distribution/` directory and run:
docker-compose up docker-compose up

View file

@ -1 +1,2 @@
COMPOSE_PROJECT_NAME=osbuild COMPOSE_PROJECT_NAME=osbuild
CONTAINER_CONFIG_DIR=../containers/config

View file

@ -6,7 +6,7 @@ services:
context: .. context: ..
dockerfile: ./distribution/Dockerfile-ubi dockerfile: ./distribution/Dockerfile-ubi
volumes: volumes:
- ../containers/config:/etc/osbuild-composer - ${CONTAINER_CONFIG_DIR}/:/etc/osbuild-composer
networks: networks:
net: net:
ipv4_address: 172.30.0.10 ipv4_address: 172.30.0.10
@ -18,7 +18,7 @@ services:
# override the entrypoint to specify composer hostname and port # override the entrypoint to specify composer hostname and port
entrypoint: /usr/libexec/osbuild-composer/osbuild-worker composer:8700 entrypoint: /usr/libexec/osbuild-composer/osbuild-worker composer:8700
volumes: volumes:
- ../containers/config:/etc/osbuild-composer - ${CONTAINER_CONFIG_DIR}/:/etc/osbuild-composer
environment: environment:
- CACHE_DIRECTORY=/var/cache/osbuild-worker - CACHE_DIRECTORY=/var/cache/osbuild-worker
privileged: true privileged: true