Skip to content

Commit b4940ae

Browse files
feat(fips): add centralized image building workflow (#89)
* add workflow for building and publishing builder image * add go matrix to build images for multiple go versions * add ubuntu matrix to build images for multiple base os versions * allow manual run for the workflow * simplify workflow * add comment for buildvcs * add go bin path to the os path in dockerfile
1 parent fff970d commit b4940ae

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and Push Builder Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-and-push:
10+
name: Build and Push Builder Image
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
go-version: [1.22.9, 1.23.2]
16+
ubuntu-version: [16.04]
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v2
24+
25+
- name: Log in to GitHub Container Registry
26+
uses: docker/login-action@v2
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Build and push Docker image
33+
uses: docker/build-push-action@v4
34+
with:
35+
context: .
36+
file: build/Dockerfile
37+
build-args: |
38+
GO_VERSION=${{ matrix.go-version }}
39+
UBUNTU_VERSION=${{ matrix.ubuntu-version }}
40+
push: true
41+
tags: |
42+
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest-go${{ matrix.go-version }}-ubuntu${{ matrix.ubuntu-version }}

build/Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
ARG UBUNTU_VERSION=16.04
2+
3+
# Use Ubuntu as the base image
4+
FROM ubuntu:${UBUNTU_VERSION}
5+
6+
ARG GO_VERSION=1.23.2
7+
ARG ARCH='amd64'
8+
ARG GH_VERSION='2.61.0'
9+
10+
# Install dependencies
11+
RUN apt-get update && apt-get install -y \
12+
gnupg-agent \
13+
unzip \
14+
zip \
15+
curl \
16+
wget \
17+
expect \
18+
git \
19+
tar \
20+
gcc \
21+
jq \
22+
g++ \
23+
gnupg2 \
24+
gnupg-agent \
25+
debsigs \
26+
rpm \
27+
build-essential \
28+
software-properties-common \
29+
python-software-properties \
30+
gcc-arm-linux-gnueabi \
31+
dpkg-sig \
32+
gcc-aarch64-linux-gnu
33+
34+
# Install Go
35+
RUN curl -sSL https://golang.org/dl/go${GO_VERSION}.linux-${ARCH}.tar.gz -o go${GO_VERSION}.linux-${ARCH}.tar.gz && \
36+
tar -C /usr/local -xzf go${GO_VERSION}.linux-${ARCH}.tar.gz && \
37+
rm go${GO_VERSION}.linux-${ARCH}.tar.gz
38+
39+
# Set Go environment variables
40+
ENV PATH="/usr/local/go/bin:/go/bin:${PATH}"
41+
ENV GOPATH="/go"
42+
43+
# Default value of -buildvcs is auto, more info:
44+
# https://github.com/kubernetes-sigs/gateway-api/pull/2302#issuecomment-1855818388
45+
ENV GOFLAGS="-buildvcs=false"
46+
47+
# Since the user does not match the owners of the repo "git rev-parse --is-inside-work-tree" fails and goreleaser does not populate projectName
48+
# https://stackoverflow.com/questions/72978485/git-submodule-update-failed-with-fatal-detected-dubious-ownership-in-repositor
49+
RUN git config --global --add safe.directory '*'
50+
RUN curl -L https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.deb -o gh_${GH_VERSION}_linux_amd64.deb
51+
RUN dpkg -i gh_${GH_VERSION}_linux_amd64.deb

0 commit comments

Comments
 (0)