From a809bc6c6afa2e6f0a2b64e4fedda3563d6c2161 Mon Sep 17 00:00:00 2001 From: titavare Date: Wed, 19 Jun 2024 11:32:47 +0200 Subject: [PATCH 1/2] Adding when pr is merged automatically create both images --- .github/workflows/build_docker_dependencies_image.yml | 6 +++++- .github/workflows/build_docker_image.yml | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_docker_dependencies_image.yml b/.github/workflows/build_docker_dependencies_image.yml index 011c00b..5b49b66 100644 --- a/.github/workflows/build_docker_dependencies_image.yml +++ b/.github/workflows/build_docker_dependencies_image.yml @@ -8,7 +8,11 @@ on: - 'v*' paths: - dockerfiles/microservices-dependencies.dockerfile - + pull_request: + types: [closed] + branches: + - develop + workflow_dispatch: jobs: diff --git a/.github/workflows/build_docker_image.yml b/.github/workflows/build_docker_image.yml index bde9a02..6a042ad 100644 --- a/.github/workflows/build_docker_image.yml +++ b/.github/workflows/build_docker_image.yml @@ -8,6 +8,10 @@ on: - 'v*' paths: - Dockerfile + pull_request: + types: [closed] + branches: + - develop workflow_dispatch: From fe84abfe98325b02a192f348e900c36e6447c210 Mon Sep 17 00:00:00 2001 From: titavare Date: Wed, 19 Jun 2024 11:34:34 +0200 Subject: [PATCH 2/2] added more information on how to create images using the actions or locally --- docs/README.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/docs/README.md b/docs/README.md index 40b8b0f..83859a0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,19 +2,36 @@ To run one of the provided microservices in this repo, the basic command is the following: ``` -docker run --rm -e MICROSERVICE= ghcr.io/dune-daq/microservices:9685 +docker run --rm -e MICROSERVICE= ghcr.io/dune-daq/microservices:develop ``` There are a couple of points to note: * The value of MICROSERVICE should be the name of a given microservice's subdirectory in this repo. As of Oct-6-2023, the available subdirectories are: `config-service`, `ers-dbwriter`, `ers-protobuf-dbwriter`, `logbook`, `opmon-dbwriter`, `runnumber-rest` and `runregistry-rest`. * Most microservices require additional environment variables to be set, which can be passed using the usual docker syntax: `-e VARIABLE_NAME=` * If you don't know what these additional environment variables are, you can just run the `docker` command as above without setting them; the container will exit out almost immediately but only after telling you what variables are missing -* The `9685` tag for the image in the example above just refers to the first four characters of the git commit of the microservices repo whose `dockerfiles/Dockerfile.microservices` Docker file was used to create the image. Currently [Dec-08-2023] this is the head of a branch soon to be merged in develop with a PR. +* The microservices image tag will be `microservices:` or `microservices:`, i.e. `microservices:develop`. +* The microservices dependency image tag is `microservices_dependencies:` or `microservices_dependencies:` For details on a given microservice, look at its own README file (format is `docs/README_.md`). They may or may not be up to date, however. -## building images -When building from a branch that is not develop you need to specify the branch you want to use to build the code, e.g.: +## Building images +There are two workflow actions on GitHub to build the `microservices` and `microservices_dependencies` images. This can be run on GitHub directly and will create the images, tag them and push them for use. + +The `microservices_dependencies` image is used as the base image for `microservies` and so any changes to the `requirements.txt` file requires rebuilding the `microservices_dependencies` image. + +If you do not wish to to push your changes to the repo when testing, you can also use: + ```bash -docker build -f Dockerfile.microservices -t ghcr.io/dune-daq/microservices:user-my-branch --build-arg BRANCH=my-branch . +docker build -f Dockerfile -t ghcr.io/dune-daq/microservices:user-my-branch . + +docker push ghcr.io/dune-daq/microservices:user-my-branch ``` +and + +```bash +docker build -f dockerfiles/microservices-dependencies.dockerfile -t ghcr.io/dune-daq/microservices_dependencies:user-my-branch /dockerfiles + +docker push ghcr.io/dune-daq/microservices_dependencies:user-my-branch +``` + +This will copy your current microservices directory. \ No newline at end of file