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 Windows and more Linux platforms to the multi-arch image #110

Merged
merged 8 commits into from
Mar 1, 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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ testresources/
.gitignore
.golangci.yml
Dockerfile
**/Dockerfile
main_test.go
README.md
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,15 @@ updates:
day: sunday
open-pull-requests-limit: 3
rebase-strategy: disabled
- package-ecosystem: docker
directory: /linux
schedule:
interval: monthly
- package-ecosystem: docker
directory: /testresources
schedule:
interval: monthly
- package-ecosystem: docker
directory: /windows
schedule:
interval: monthly
99 changes: 67 additions & 32 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ name: Test & Build multi-arch Docker Image

on:
push:
branches: [main]
branches: [ main ]
pull_request:

env:
IMAGE_REPOSITORY: testcontainers/ryuk

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version-file: 'go.mod'
- run: go version

- name: Check out code into the Go module directory
uses: actions/checkout@v3

- name: go-mod verify
run: go mod verify

Expand All @@ -32,33 +35,65 @@ jobs:
- name: go-test
run: go test -v ./...

build-image-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: go version

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Docker info
run: docker info
- name: Buildx inspect
run: docker buildx inspect

- name: Build image
uses: docker/build-push-action@v3
with:
context: .
file: linux/Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v6
push: false
# Use a 'temp' tag, that won't be pushed for non-release builds
tags: ${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name || 'temp' }}-linux

build-image-windows:
strategy:
matrix:
os-version:
- ltsc2019
- ltsc2022
runs-on: windows-2022
mdelapenya marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- run: go version

- name: Docker info
run: docker info

- name: Build image
# Use a 'temp' tag, that won't be pushed for non-release builds
run: |
docker build -f windows/Dockerfile --build-arg BASE_IMAGE=mcr.microsoft.com/windows/nanoserver:${{ matrix.os-version }} -t ${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name || 'temp' }}-windows.amd64.${{ matrix.os-version }} .

build:
runs-on: ubuntu-latest
needs: test
needs:
- test
- build-image-linux
- build-image-windows
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v5
with:
go-version: '1.21'
- run: go version

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Docker info
run: docker info
- name: Buildx inspect
run: docker buildx inspect

- name: Build image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
push: false
# Use a 'temp' tag, that won't be pushed, for non-release builds
tags: testcontainers/ryuk:${{ github.event.release.tag_name || 'temp' }}
- name: join point for test, linux build, and windows build
run: |
echo "done"
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21
- uses: actions/checkout@v3
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3
with:
Expand Down
206 changes: 157 additions & 49 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,165 @@ name: Release multi-arch Docker Image

on:
release:
types: [published]
types: [ published ]

env:
IMAGE_REPOSITORY: testcontainers/ryuk

jobs:
release:
release-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v5
with:
go-version: '1.21'
- run: go version

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: go-mod verify
run: go mod verify

- name: go-mod tidy
run: go mod tidy

- name: go-build
env:
GOOS: linux
run: go build

- name: go-test
run: go test -v ./...

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Docker info
run: docker info
- name: Buildx inspect
run: docker buildx inspect

- name: Build and push image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: go version

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: go-mod verify
run: go mod verify

- name: go-mod tidy
run: go mod tidy

- name: go-build
env:
GOOS: linux
run: go build

- name: go-test
run: go test -v ./...

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Docker info
run: docker info
- name: Buildx inspect
run: docker buildx inspect

- name: Build and push image
uses: docker/build-push-action@v3
with:
context: .
file: linux/Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v6
# Only push if we are publishing a release
push: true
tags: ${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }}-linux

release-windows:
strategy:
matrix:
os-version:
- ltsc2019
- ltsc2022
runs-on: windows-2022
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- run: go version

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: go-mod verify
run: go mod verify

- name: go-mod tidy
run: go mod tidy

- name: go-build
env:
GOOS: windows
run: go build

#- name: go-test
# run: go test -v ./...

- name: Docker info
run: docker info

- name: Build image
run: |
docker build -f windows/Dockerfile --build-arg BASE_IMAGE=mcr.microsoft.com/windows/nanoserver:${{ matrix.os-version }} -t ${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }}-windows.amd64.${{ matrix.os-version }} .

- name: Push image
# Only push if we are publishing a release
push: true
tags: testcontainers/ryuk:${{ github.event.release.tag_name }}
run: |
docker push ${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }}-windows.amd64.${{ matrix.os-version }}

release:
needs:
- release-linux
- release-windows
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Docker info
run: docker info
- name: Buildx inspect
run: docker buildx inspect

- name: Get os version for nanoserver:ltsc2019
run: >-
full_version=$(docker manifest inspect mcr.microsoft.com/windows/nanoserver:ltsc2019 | jq -r '.manifests[]|.platform|."os.version"'| sed 's@.*:@@') || true;
echo "OS_VERSION_ltsc2019=${full_version}" >> $GITHUB_ENV;

- name: Get os version for nanoserver:ltsc2022
run: >-
full_version=$(docker manifest inspect mcr.microsoft.com/windows/nanoserver:ltsc2022 | jq -r '.manifests[]|.platform|."os.version"'| sed 's@.*:@@') || true;
echo "OS_VERSION_ltsc2022=${full_version}" >> $GITHUB_ENV;

- name: Docker Manifest
run: >-
target_image=${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name }};
linux_manifest=$(docker manifest inspect ${target_image}-linux);
linux_digests=$(docker manifest inspect ${target_image}-linux | jq -r '.manifests[].digest');
manifest_list=${linux_digests//sha256:/${target_image%%:*}@sha256:};
manifest_list+=" ${target_image}-windows.amd64.ltsc2019";
manifest_list+=" ${target_image}-windows.amd64.ltsc2022";
docker manifest create ${target_image} ${manifest_list};
docker manifest annotate \
--os-version ${OS_VERSION_ltsc2019} \
--os windows \
--arch amd64 \
${target_image} "${target_image}-windows.amd64.ltsc2019";
docker manifest annotate \
--os-version ${OS_VERSION_ltsc2022} \
--os windows \
--arch amd64 \
${target_image} "${target_image}-windows.amd64.ltsc2022";
docker manifest push ${target_image};
File renamed without changes.
2 changes: 1 addition & 1 deletion testresources/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM nginx:alpine
FROM nginx:alpine
Loading
Loading