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

Add 32-bit variant of the mingw-w64 image #1441

Merged
merged 1 commit into from
Mar 23, 2024
Merged
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
45 changes: 41 additions & 4 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ jobs:
- name: List generated Docker images
run: docker image ls --filter "label=atc0005.go-ci" --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}"

build_stable_cgo-mingw-w64_image_using_makefile:
name: Build stable cgo-mingw-w64 image using Makefile
build_stable_cgo-mingw-w64_x64_image_using_makefile:
name: Build stable cgo-mingw-w64 x64 image using Makefile
needs: git_describe_semver
runs-on: ubuntu-latest
# Default: 360 minutes
Expand Down Expand Up @@ -472,10 +472,47 @@ jobs:
- name: Install Ubuntu packages
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make gcc bsdmainutils

- name: Build stable cgo-mingw-w64 image
- name: Build stable cgo-mingw-w64 x64 image
run: |
export REPO_VERSION=${{ needs.git_describe_semver.outputs.version }}
make stable-cgo-mingw-w64-build
make stable-cgo-mingw-w64-buildx64

- name: List generated Docker images
run: docker image ls --filter "label=atc0005.go-ci" --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}"

build_stable_cgo-mingw-w64_x86_image_using_makefile:
name: Build stable cgo-mingw-w64 x86 image using Makefile
needs: git_describe_semver
runs-on: ubuntu-latest
# Default: 360 minutes
timeout-minutes: 10

steps:
- name: Print Docker version
run: docker --version

- name: Clone repo with default settings
uses: actions/checkout@v4

# Mark the current working directory as a safe directory in git to
# resolve "dubious ownership" complaints.
#
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
# https://confluence.atlassian.com/bbkb/git-command-returns-fatal-error-about-the-repository-being-owned-by-someone-else-1167744132.html
# https://github.com/actions/runner-images/issues/6775
# https://github.com/actions/checkout/issues/766
- name: Mark the current working directory as a safe directory in git
# run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
run: git config --global --add safe.directory "${PWD}"

# bsdmainutils provides "column" which is used by the Makefile
- name: Install Ubuntu packages
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends make gcc bsdmainutils

- name: Build stable cgo-mingw-w64 x86 image
run: |
export REPO_VERSION=${{ needs.git_describe_semver.outputs.version }}
make stable-cgo-mingw-w64-buildx86

- name: List generated Docker images
run: docker image ls --filter "label=atc0005.go-ci" --format "table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.Size}}"
Expand Down
54 changes: 39 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ DOCKER_IMAGE_NAME_MIRROR_BUILD_GO120 = go-ci-mirror-build-go1.20
DOCKER_IMAGE_NAME_MIRROR_BUILD_GO121 = go-ci-mirror-build-go1.21
DOCKER_IMAGE_NAME_MIRROR_BUILD_GO122 = go-ci-mirror-build-go1.22

DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD = go-ci-stable-cgo-mingw-w64-build
DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86 = go-ci-stable-cgo-mingw-w64-buildx86
DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64 = go-ci-stable-cgo-mingw-w64-buildx64

DOCKER_IMAGE_NAME_OLDSTABLE_ALPINE_BUILDX86 = go-ci-oldstable-alpine-buildx86
DOCKER_IMAGE_NAME_OLDSTABLE_ALPINE_BUILDX64 = go-ci-oldstable-alpine-buildx64
DOCKER_IMAGE_NAME_STABLE_ALPINE_BUILDX86 = go-ci-stable-alpine-buildx86
Expand Down Expand Up @@ -284,23 +286,41 @@ build-unstable-alpine-buildx86: pre-build
--label=$(DOCKER_IMAGE_CREATED_LABEL)
@echo "Completed build of $(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX86) release"

.PHONY: stable-cgo-mingw-w64-build
## stable-cgo-mingw-w64-build: Build cgo-mingw-w64 image
stable-cgo-mingw-w64-build: pre-build
.PHONY: stable-cgo-mingw-w64-buildx64
## stable-cgo-mingw-w64-buildx64: Build cgo-mingw-w64 image
stable-cgo-mingw-w64-buildx64: pre-build

@echo "Building $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64) release"
sudo docker image build \
--pull \
--no-cache \
stable/build/cgo-mingw-w64-x64/ \
-t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64) \
-t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64)-$(REPO_VERSION) \
-t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64) \
-t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64)-$(REPO_VERSION) \
--label=$(DOCKER_IMAGE_OWNER_LABEL) \
--label=$(DOCKER_IMAGE_REVISION_LABEL) \
--label=$(DOCKER_IMAGE_CREATED_LABEL)
@echo "Completed build of $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64) release"

.PHONY: stable-cgo-mingw-w64-buildx86
## stable-cgo-mingw-w64-buildx86: Build cgo-mingw-w64 image
stable-cgo-mingw-w64-buildx86: pre-build

@echo "Building $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD) release"
@echo "Building $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86) release"
sudo docker image build \
--pull \
--no-cache \
stable/build/cgo-mingw-w64/ \
-t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD) \
-t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD)-$(REPO_VERSION) \
-t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD) \
-t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD)-$(REPO_VERSION) \
stable/build/cgo-mingw-w64-x86/ \
-t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86) \
-t $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86)-$(REPO_VERSION) \
-t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86) \
-t $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(GITHUB_PROJECT_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86)-$(REPO_VERSION) \
--label=$(DOCKER_IMAGE_OWNER_LABEL) \
--label=$(DOCKER_IMAGE_REVISION_LABEL) \
--label=$(DOCKER_IMAGE_CREATED_LABEL)
@echo "Completed build of $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD) release"
@echo "Completed build of $(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86) release"

.PHONY: legacy-mirror-build
## legacy-mirror-build: Build legacy mirror images
Expand Down Expand Up @@ -573,8 +593,10 @@ upload:
@sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX86)-$(REPO_VERSION)
@sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX64)
@sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX64)-$(REPO_VERSION)
@sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD)
@sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD)-$(REPO_VERSION)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86)-$(REPO_VERSION)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64)-$(REPO_VERSION)

@sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_OLDSTABLE_MIRROR_BUILD)
@sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(GITHUB_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_OLDSTABLE_MIRROR_BUILD)-$(REPO_VERSION)
Expand Down Expand Up @@ -636,8 +658,10 @@ upload:
@sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX86)-$(REPO_VERSION)
@sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX64)
@sudo docker push $(GITHUB_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_UNSTABLE_ALPINE_BUILDX64)-$(REPO_VERSION)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILD)-$(REPO_VERSION)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX86)-$(REPO_VERSION)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_CGO-MINGW-W64_BUILDX64)-$(REPO_VERSION)

@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_OLDSTABLE_MIRROR_BUILD)
@sudo docker push $(DOCKER_IMAGE_REGISTRY)/$(DOCKER_IMAGE_REGISTRY_USER)/$(DOCKER_IMAGE_REPO):$(DOCKER_IMAGE_NAME_OLDSTABLE_MIRROR_BUILD)-$(REPO_VERSION)
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Tooling for linting, testing and building Go applications
- [`go-ci-stable-alpine-buildx64`](#go-ci-stable-alpine-buildx64)
- [`go-ci-unstable-alpine-buildx86`](#go-ci-unstable-alpine-buildx86)
- [`go-ci-unstable-alpine-buildx64`](#go-ci-unstable-alpine-buildx64)
- [`go-ci-stable-cgo-mingw-w64-build`](#go-ci-stable-cgo-mingw-w64-build)
- [`go-ci-stable-cgo-mingw-w64-buildx86`](#go-ci-stable-cgo-mingw-w64-buildx86)
- [`go-ci-stable-cgo-mingw-w64-buildx64`](#go-ci-stable-cgo-mingw-w64-buildx64)
- [Mirror build images](#mirror-build-images)
- [`go-ci-mirror-build-*`](#go-ci-mirror-build-)
- [`go-ci-oldstable-mirror-build`](#go-ci-oldstable-mirror-build)
Expand Down Expand Up @@ -196,7 +197,7 @@ the `*-mirror-*` images:
- ✔️ provides multiple [custom build tools](#build-tools-included)
- ❌ does not include [linters](#linting-tools-included)

#### `go-ci-stable-cgo-mingw-w64-build`
#### `go-ci-stable-cgo-mingw-w64-buildx86`

- built from the latest version of the current stable `golang` image.
- used for building and testing Go applications, both directly and via
Expand All @@ -207,6 +208,13 @@ the `*-mirror-*` images:
- ✔️ provides multiple [custom build tools](#build-tools-included)
- ❌ does not include [linters](#linting-tools-included)

#### `go-ci-stable-cgo-mingw-w64-buildx64`

- same as `go-ci-stable-cgo-mingw-w64-buildx86`, but specific to x64
architecture
- ✔️ provides multiple [custom build tools](#build-tools-included)
- ❌ does not include [linters](#linting-tools-included)

### Mirror build images

#### `go-ci-mirror-build-*`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci"
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
LABEL org.opencontainers.image.documentation="https://github.com/atc0005/go-ci"
LABEL org.opencontainers.image.url="https://github.com/atc0005/go-ci"
LABEL org.opencontainers.image.title="go-ci-stable-cgo-mingw-w64-build"
LABEL org.opencontainers.image.title="go-ci-stable-cgo-mingw-w64-buildx64"
LABEL org.opencontainers.image.description="Docker container image used to build dev and stable \
releases of Go code. Based on the latest version of the current stable golang image. \
releases of Go code. Based on the latest version of the current stable x64 golang image. \
Supports static, cgo-enabled builds via mingw."
LABEL org.opencontainers.image.authors="Adam Chalkley (github.com/atc0005)"

Expand Down
63 changes: 63 additions & 0 deletions stable/build/cgo-mingw-w64-x86/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2020 Adam Chalkley
#
# https://github.com/atc0005/go-ci
#
# Licensed under the MIT License. See LICENSE file in the project root for
# full license information.

# https://hub.docker.com/r/i386/golang

FROM i386/golang:1.22.1-bookworm

# https://docs.github.com/en/packages/learn-github-packages/connecting-a-repository-to-a-package
LABEL org.opencontainers.image.source="https://github.com/atc0005/go-ci"

# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
LABEL org.opencontainers.image.documentation="https://github.com/atc0005/go-ci"
LABEL org.opencontainers.image.url="https://github.com/atc0005/go-ci"
LABEL org.opencontainers.image.title="go-ci-stable-cgo-mingw-w64-buildx86"
LABEL org.opencontainers.image.description="Docker container image used to build dev and stable \
releases of Go code. Based on the latest version of the current stable x86 golang image. \
Supports static, cgo-enabled builds via mingw."
LABEL org.opencontainers.image.authors="Adam Chalkley (github.com/atc0005)"

# Explicitly disable automatic fetching of Go toolchains newer than the
# version explicitly provided by this container image.
#
# https://github.com/atc0005/go-ci/issues/1188
ENV GOTOOLCHAIN="local"

ENV APT_BSDMAINUTILS_VERSION="12.1.8"
ENV APT_TREE_VERSION="2.1.0-1"
ENV APT_GCC_MULTILIB_VERSION="4:12.2.0-3"
ENV APT_GCC_MINGW_W64_VERSION="12.2.0-14+25.2"
ENV XZ_UTILS_VERSION="5.4.1-0.2"

# https://github.com/tc-hib/go-winres/releases
ENV GO_WINRES_VERSION="v0.3.1"

# https://github.com/goreleaser/nfpm/releases
ENV NFPM_VERSION="v2.35.3"

# https://github.com/choffmeister/git-describe-semver/releases
ENV GIT_DESCRIBE_SEMVER_VERSION="v0.4.0"

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bsdmainutils="${APT_BSDMAINUTILS_VERSION}" \
tree="${APT_TREE_VERSION}" \
gcc-multilib="${APT_GCC_MULTILIB_VERSION}" \
gcc-mingw-w64="${APT_GCC_MINGW_W64_VERSION}" \
xz-utils="${XZ_UTILS_VERSION}" \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
\
&& echo "Installing go-winres@${GO_WINRES_VERSION}" \
&& go install github.com/tc-hib/go-winres@${GO_WINRES_VERSION} \
&& go version -m $(which go-winres) | awk '$1 == "mod" { print $3 }' \
&& echo "Installing nfpm@${NFPM_VERSION}" \
&& go install github.com/goreleaser/nfpm/v2/cmd/nfpm@${NFPM_VERSION} \
&& nfpm --version \
&& go install github.com/choffmeister/git-describe-semver@${GIT_DESCRIBE_SEMVER_VERSION} \
&& go version -m $(which git-describe-semver) | awk '$1 == "mod" { print $3 }' \
&& go clean -cache -modcache