Skip to content

Latest commit

 

History

History
54 lines (39 loc) · 2.22 KB

automatic-build-and-upload-of-private-dockers.md

File metadata and controls

54 lines (39 loc) · 2.22 KB
description
Guide to build and upload on Docker hub from private Github repositories

Automatic Build and Upload of Private Dockers

Docker Hub

  1. Create a private repository on Docker Hub for all dockers that will be uploaded.
  2. Make sure a 'bot' user is created on Docker Hub that has read/write access to these repositories
  3. Create an access token for this user. (Refer Docker Hub docs)

Creation of Github actions

  1. Clone the private repo on the command line (example, openg2p-myrepo)
  2. Under openg2p-myrepo/.github folder create the following folder structure
.github/
├── docker_packages
└── workflows
  1. Inside docker_packages folder create package files for modules like Social Registry, PBMS, etc. See sample package files. Replace openg2p-myrepo with your private repo name.
  2. Run following command in your private repo root folder openg2p-myrepo/:
git submodule add https://github.com/openg2p/openg2p-packaging .github/docker_packaging

This will clone openg2p-packaging repo into the docker_packaging folder. The folder structure will look like

.github/
├── docker_packages
|── docker_packaging
└── workflows
  1. Inside workflows folder copy docker_build.yml and modify the following for your repo:
    1. Set SERVICE_NAME to name of your Docker Hub repository
    2. Replace openg2p-myrepo with your repo name
  2. Check in all the above.

Enabling Github actions

  1. Under Secrets and variables->Actions create the following secrets:
    • DOCKER_HUB_ACTOR: Docker Hub user id that has permission to read/write the above registry
    • DOCKER_HUB_ORGANIZATION: Organization under which your private repo resides
    • DOCKER_HUB_TOKEN: Access token for this user on Docker Hub
  2. Under your private repo Settings->Actions->General, enable "Allow all actions and reusable workflows"

Run

The above workflow will automatically run when a PR is merged into the private repo. Dockers will be built and posted to Docker Hub.