Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and push docker/docker-compose images upon release #9787

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ env:
GO_VERSION: "1.18.5" # for non sandboxed e2e tests
DESTDIR: "./bin"
DOCKER_CLI_VERSION: "20.10.17"
REPO_SLUG: "docker/docker-compose"

jobs:
prepare:
Expand Down Expand Up @@ -223,3 +224,49 @@ jobs:
generateReleaseNotes: true
draft: true
token: ${{ secrets.GITHUB_TOKEN }}

bin-image:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
version: latest
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REPO_SLUG }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push image
uses: docker/bake-action@v2
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: release-image
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
set: |
*.cache-from=type=gha,scope=bin-image
*.cache-to=type=gha,scope=bin-image,mode=max
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,9 @@ COPY --from=releaser /out/ /
# see open-pr job in .github/workflows/docs.yml for more details
FROM scratch AS docs-reference
COPY docs/reference/*.yaml .

FROM base AS release-image
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base image is go/alpine, with docker and git installed in it. Anything else that we think should go in here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice we're installing docker from alpine's apk repositories, which are builds of docker built by alpine. Perhaps that's ok for testing, but we definitely should not ship those as part of images for end-users.

Having a "runnable" compose image with docker installed basically replicates the official docker:cli image; see docker-library/docker#369

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I think basing compose off the official docker cli image would be a lot better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nevermind! Compose is in the latest docker:*-cli images. Then I'll see if we can use that.

WORKDIR /root
COPY --link --from=build /usr/bin/docker-compose /usr/bin/
RUN mkdir -p /usr/local/lib/docker/cli-plugins
RUN ln -s /usr/bin/docker-compose /usr/local/lib/docker/cli-plugins/
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ build-and-e2e: compose-plugin e2e-compose e2e-compose-standalone ## Compile the
cross: ## Compile the CLI for linux, darwin and windows
$(BUILDX_CMD) bake binary

.PHONY: image
image: ## Build the docker/docker-compose image locally and load it into Docker
$(BUILDX_CMD) bake image

.PHONY: test
test: ## Run unit tests
$(BUILDX_CMD) bake test
Expand Down
20 changes: 20 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,23 @@ target "docs-update" {
target = "docs-update"
output = ["./docs"]
}

target "docker-metadata-action" {}

target "release-image" {
inherits = ["docker-metadata-action"]
target = "release-image"
platforms = [
"linux/amd64",
"linux/arm/v6",
"linux/arm/v7",
"linux/arm64",
]
}

target "image" {
inherits = ["release-image"]
platforms = []
tags = ["docker.io/docker/docker-compose"]
output = ["type=docker"]
}