From 600a07a010b601325ea75af159021d6f3b258fbc Mon Sep 17 00:00:00 2001 From: James Jones Date: Mon, 21 Nov 2022 16:03:41 -0500 Subject: [PATCH 1/6] Adding on github actions --- .github/workflows/build.yml | 61 +++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ffb0eec..735928b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,33 +34,34 @@ jobs: login-server: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push Docker images - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - # - name: Build the Docker image - # run: | - # if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then - # VERSION=$GITHUB_REF_NAME - # else - # VERSION=$(echo "${GITHUB_REF_NAME}" | sed 's|/|-|g') - # fi - # podman build . --file Dockerfile --tag "ghcr.io/$IMAGE_NAME:$VERSION" - # echo $REG_TOKEN | podman login ghcr.io -u ${GITHUB_ACTOR} --password-stdin - # podman push "ghcr.io/$IMAGE_NAME:$VERSION" - # if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then - # podman tag "ghcr.io/$IMAGE_NAME:$VERSION" "$IMAGE_NAME:latest" - # podman push "ghcr.io/$IMAGE_NAME:latest" - # fi - # env: - # REG_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # # REG_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} - # IMAGE_NAME: jamesjonesconsulting/podman-dind-like + # This requires docker buildx which podman doesn't support + # - name: Extract metadata (tags, labels) for Docker + # id: meta + # uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + # with: + # images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # - name: Build and push Docker images + # uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + # with: + # context: . + # push: true + # tags: ${{ steps.meta.outputs.tags }} + # labels: ${{ steps.meta.outputs.labels }} + - name: Build the Docker image + run: | + if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then + VERSION=$GITHUB_REF_NAME + else + VERSION=$(echo "${GITHUB_REF_NAME}" | sed 's|/|-|g') + fi + podman build . --file Dockerfile --tag "$REGISTRY/$IMAGE_NAME:$VERSION" + # echo $REG_TOKEN | podman login ghcr.io -u ${GITHUB_ACTOR} --password-stdin + podman push "$REGISTRY/$IMAGE_NAME:$VERSION" + if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then + podman tag "$REGISTRY/$IMAGE_NAME:$VERSION" "$IMAGE_NAME:latest" + podman push "$REGISTRY/$IMAGE_NAME:latest" + fi + # env: + # REG_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # # REG_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} + # IMAGE_NAME: jamesjonesconsulting/podman-dind-like From ab5927dd90faf7f03780e4b0a9bbbafc41409453 Mon Sep 17 00:00:00 2001 From: James Jones Date: Mon, 21 Nov 2022 16:07:35 -0500 Subject: [PATCH 2/6] Adding on github actions --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 735928b..df6f772 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + IMAGE_NAME: ${{ github.repository.lowercase }} jobs: build: From df3bee661d4949a3ea6a324741e668101c1a69a7 Mon Sep 17 00:00:00 2001 From: James Jones Date: Mon, 21 Nov 2022 16:18:21 -0500 Subject: [PATCH 3/6] Adding on github actions --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df6f772..bd3cbb5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository.lowercase }} + # IMAGE_NAME: ${{ github.repository }} jobs: build: @@ -49,13 +49,14 @@ jobs: # labels: ${{ steps.meta.outputs.labels }} - name: Build the Docker image run: | + IMAGE_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then VERSION=$GITHUB_REF_NAME else VERSION=$(echo "${GITHUB_REF_NAME}" | sed 's|/|-|g') fi podman build . --file Dockerfile --tag "$REGISTRY/$IMAGE_NAME:$VERSION" - # echo $REG_TOKEN | podman login ghcr.io -u ${GITHUB_ACTOR} --password-stdin + # echo $REG_TOKEN | podman login ${$REGISTRY} -u ${GITHUB_ACTOR} --password-stdin podman push "$REGISTRY/$IMAGE_NAME:$VERSION" if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then podman tag "$REGISTRY/$IMAGE_NAME:$VERSION" "$IMAGE_NAME:latest" From cc8ebbb20050d0d848db660d33226842c3476bbb Mon Sep 17 00:00:00 2001 From: James Jones Date: Mon, 21 Nov 2022 16:46:19 -0500 Subject: [PATCH 4/6] Adding on github actions --- .github/workflows/build.yml | 10 +++++----- README.md | 13 +++++++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bd3cbb5..c536aa0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,17 +3,19 @@ name: Build podman-dind-like on: push: branches: - - release/* - - feature/* + - 'release/**' + - 'feature/**' - develop + tags: + - '*' pull_request: branches: - main + - 'release/**' - develop env: REGISTRY: ghcr.io - # IMAGE_NAME: ${{ github.repository }} jobs: build: @@ -56,7 +58,6 @@ jobs: VERSION=$(echo "${GITHUB_REF_NAME}" | sed 's|/|-|g') fi podman build . --file Dockerfile --tag "$REGISTRY/$IMAGE_NAME:$VERSION" - # echo $REG_TOKEN | podman login ${$REGISTRY} -u ${GITHUB_ACTOR} --password-stdin podman push "$REGISTRY/$IMAGE_NAME:$VERSION" if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then podman tag "$REGISTRY/$IMAGE_NAME:$VERSION" "$IMAGE_NAME:latest" @@ -65,4 +66,3 @@ jobs: # env: # REG_TOKEN: ${{ secrets.GITHUB_TOKEN }} # # REG_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }} - # IMAGE_NAME: jamesjonesconsulting/podman-dind-like diff --git a/README.md b/README.md index c5f09e3..ff9ec78 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,18 @@ A Docker-in-Docker like container using Podman This takes the quay.io/podman/stable image and extends it with some enhancements to make it more docker like and able to use `docker` as a command as well as includes `docker-compose`. -## Notes +## Notes on Github Actions -This job runs on a self-hosted gitlab agent with the following in the `/etc/gitlab-runner/config.toml` file so this is also compatible with +This job runs on a self-hosted Github Actions agent and publishes to Github's container registry ghcr.io as a 'public' image and can be downloaded +via a simple docker command or other means as you see fit. + +``` +docker pull ghcr.io/jamesjonesconsulting/podman-dind-like:latest +``` + +## Notes on GitLab + +This job also runs on a self-hosted gitlab agent with the following in the `/etc/gitlab-runner/config.toml` file so this is also compatible with other self-hosted agents for other CI/CD self-hosted agents. ``` From 68a82f226f3643c4f312cca755cab2860b9a8a83 Mon Sep 17 00:00:00 2001 From: James Jones Date: Mon, 21 Nov 2022 16:48:20 -0500 Subject: [PATCH 5/6] Adding on github actions --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c536aa0..37ef708 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ env: REGISTRY: ghcr.io jobs: - build: + build-and-push: runs-on: self-hosted container: image: quay.io/podman/stable:latest From 2c37835a772737444c669a4940fbe09156bd929b Mon Sep 17 00:00:00 2001 From: James Jones Date: Mon, 21 Nov 2022 16:51:14 -0500 Subject: [PATCH 6/6] Adding on github actions --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ff9ec78..e4441a3 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ and able to use `docker` as a command as well as includes `docker-compose`. This job runs on a self-hosted Github Actions agent and publishes to Github's container registry ghcr.io as a 'public' image and can be downloaded via a simple docker command or other means as you see fit. +Note: The `build-push` action doesn't work with 'podman' (commented out in the pipeline) as it tightly coupled with 'buildx' which is only supported with native docker. + ``` docker pull ghcr.io/jamesjonesconsulting/podman-dind-like:latest ```