This repo contains a Docker image for tracking components to be deployed to GPII infrastructure. It works as a bridge between the independent CI projects that build, test, and upload Docker images (e.g. GPII universal) and the gpii-infra repo, which manages the infrastructure for operating and deploying GPII components.
For more about the general CI/CD picture, see Continuous Integration / Continuous Delivery in gpii-infra.
This module contains:
Rakefile, the primary entry point.sync_images.rb, which calculates the latest sha256 for each component, uploads the image to our production Google Container Registry, and writesshared/versions.ymlin the gpii-infra repo.sync_images_wrapper, a script that runssync_imagesin a loop, committing and pushingshared/versions.ymlif it changes.- This requires commit and push privileges on
gpii-infra. These privileges are provided via an ssh key and some configuration of Github.
- This requires commit and push privileges on
Dockerfile, to build a Docker image that runssync_images_wrapper.- A container based on this Docker image is deployed to
i46and managed by an Ansible role and a wrapper playbook.
- A container based on this Docker image is deployed to
- Follow the gpii-infra instructions for installing packages..
- Install the
bundlergem, e.g. withgem install bundleror with your system's package manager. - Clone this repo.
cd gpii-version-updaterrake install- To clean up:
rake uninstall
- To clean up:
rake syncto runsync_images.rb- You can override some defaults:
rake sync"[./my_versions.yml, gcr.io/gpii2test-common-stg]"
- You can override some defaults:
rake clean_cacheto destroy the Docker/var/lib/dockercache volume. The volume and cache will be re-created on the next run.rake testto run unit tests
This workflow is a little cumbersome and is probably best for debugging version-udpater itself.
docker pull gpii/version-updater- Run the container in interactive mode:
docker run --privileged --rm -it -v version-updater-docker-cache:/var/lib/docker gpii/version-updater sh- If you want to read and write the versions.yml automatically (e.g. by running
sync_images_wrapper), you must provide a directory containing aid_rsa.gpii-ciusable for pulling and pushing to the gpii-infra repo.- Add to the command line:
-v $(pwd)/fake-gpii-ci-ssh:/root/.ssh:ro,Z
- Add to the command line:
- If you want to upload images (i.e.
push_to_gcris set totrue-- this is the default forsync_images_wrapper), you must provide credentials with write access to the production GCR instance (or to the GCR instance you specified).- Add to the command line:
-v $(pwd)/creds.json:/home/app/creds.json:ro,Z
- Add to the command line:
- Omit
version-updater-docker-cacheif you want to re-pull the Docker images whenever you restart the container. Otherwise, clean up afterwards withrake clean_cache.
- If you want to read and write the versions.yml automatically (e.g. by running
- Inside the container, start dockerd in the background:
dockerd & rake sync"[/path/to/versions.yml]", etc.
sync_images can be useful for local GPII development. See gpii-infra: I want to test my local changes to GPII components in my cluster.
sync_images reads a specified versions.yml file.
Each top-level key is a component. The component's name is arbitrary, but should correlate with a gpii-infra module since gpii-infra will populate environment variables like TF_VAR_<component_name>_(repository|tag|sha) based on data under the component key in versions.yml.
sync_images pulls the image specified by the component's upstream.image and upstream.tag keys, optionally processes the image further (e.g. pushing it to GCR), then populates the component's generated key with caluclated values.
- Add a new top-level key,
my_component.- Use
snake_case, notkebab-case.
- Use
- Add a key underneath
my_componentcalledrepository. Its value is the upstream location of the image, e.g.mrtyler/universalorcouchdb. - Add a key underneath
my_componentcalledtag. Its value is the tag on the upstream repository, e.g.latestor2.3. rake sync"[/path/to/gpii-infra/shared/versions.yml, my_component]"desired_components(themy_componentarg) accepts multiple, pipe-separated values:flowmanager|preferences|dataloader
- Review the changes made to
versions.ymland commit.
- Find the component, e.g.
your_component. - Modify
repositoryandtag. - Ignore everything under
generated; it will be re-generated. rake sync"[/path/to/gpii-infra/shared/versions.yml, your_component]"- Review the changes made to
versions.ymland commit.
- For local development:
rake clean_cache - For the production instance on i46: this machine does not provide a helpful development environment (no rake, no git) so it may be easier to:
docker killthe runningversion-updatercontainer- Manually run the commands in the Rakefile's
task :clean_cache