Skip to content

Commit

Permalink
Use mirror.gcr.io as pull-through cache
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Jul 16, 2024
1 parent 1ba1b52 commit da07df0
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 23 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
Expand All @@ -35,14 +42,24 @@ jobs:
env:
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
- name: Test
run: |
dapper -f Dockerfile --target dapper make test
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
build-arm64:
runs-on: runs-on,runner=8cpu-linux-arm64,run-id=${{ github.run_id }},image=ubuntu22-full-arm64,hdd=64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
Expand All @@ -59,4 +76,4 @@ jobs:
env:
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}

BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
21 changes: 20 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,45 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
- name: Test
run: |
dapper -f Dockerfile --target dapper make test
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
build-arm64:
runs-on: runs-on,runner=8cpu-linux-arm64,run-id=${{ github.run_id }},image=ubuntu22-full-arm64,hdd=64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up buildx
uses: docker/setup-buildx-action@v3
id: buildx
with:
buildkitd-config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
- name: Install Dapper
run: |
curl -sL https://releases.rancher.com/dapper/latest/dapper-$(uname -s)-$(uname -m) > /usr/local/bin/dapper
chmod +x /usr/local/bin/dapper
- name: Build
run: |
dapper -f Dockerfile --target dapper make dapper-ci
env:
BUILDX_BUILDER: ${{ steps.buildx.outputs.name }}
22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG KUBERNETES_VERSION=dev
# Build environment
FROM rancher/hardened-build-base:v1.22.4b1 AS build
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ENV ARCH="$DAPPER_HOST_ARCH"
RUN set -x && \
apk --no-cache add \
bash \
Expand Down Expand Up @@ -31,13 +31,13 @@ RUN zypper install -y systemd-rpm-macros

# Dapper/Drone/CI environment
FROM build AS dapper
ENV DAPPER_ENV GODEBUG GOCOVER REPO TAG GITHUB_ACTION_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY DOCKER_USERNAME DOCKER_PASSWORD
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ENV DAPPER_OUTPUT ./dist ./bin ./build
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_TARGET dapper
ENV DAPPER_RUN_ARGS "--privileged --network host -v /tmp:/tmp -v rke2-pkg:/go/pkg -v rke2-cache:/root/.cache/go-build -v trivy-cache:/root/.cache/trivy"
ENV ARCH="$DAPPER_HOST_ARCH"
ENV DAPPER_ENV="GODEBUG GOCOVER REPO TAG GITHUB_ACTION_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY DOCKER_USERNAME DOCKER_PASSWORD"
ENV DAPPER_OUTPUT="./dist ./bin ./build"
ENV DAPPER_DOCKER_SOCKET="true"
ENV DAPPER_TARGET="dapper"
ENV DAPPER_RUN_ARGS="--privileged --network host -v /home/runner/.docker:/root/.docker -v /tmp:/tmp -v rke2-pkg:/go/pkg -v rke2-cache:/root/.cache/go-build -v trivy-cache:/root/.cache/trivy"
RUN if [ "${ARCH}" = "amd64" ] || [ "${ARCH}" = "arm64" ]; then \
VERSION=0.56.10 OS=linux && \
curl -sL "https://github.com/vmware-tanzu/sonobuoy/releases/download/v${VERSION}/sonobuoy_${VERSION}_${OS}_${ARCH}.tar.gz" | \
Expand Down Expand Up @@ -95,8 +95,8 @@ RUN set -x && \
RUN go get github.com/onsi/ginkgo/v2 github.com/onsi/gomega/...
RUN GO111MODULE=off GOBIN=/usr/local/bin go get github.com/go-delve/delve/cmd/dlv
RUN echo 'alias abort="echo -e '\''q\ny\n'\'' | dlv connect :2345"' >> /root/.bashrc
ENV PATH=/var/lib/rancher/rke2/bin:$PATH
ENV KUBECONFIG=/etc/rancher/rke2/rke2.yaml
ENV PATH="/var/lib/rancher/rke2/bin:$PATH"
ENV KUBECONFIG="/etc/rancher/rke2/rke2.yaml"
VOLUME /var/lib/rancher/rke2
# This makes it so we can run and debug k3s too
VOLUME /var/lib/rancher/k3s
Expand Down Expand Up @@ -156,9 +156,9 @@ COPY build/images/rke2-images.linux-amd64.tar.zst /var/lib/rancher/rke2/agent/im
COPY build/images.txt /images.txt

# use rke2 bundled binaries
ENV PATH=/var/lib/rancher/rke2/bin:$PATH
ENV PATH="/var/lib/rancher/rke2/bin:$PATH"
# for kubectl
ENV KUBECONFIG=/etc/rancher/rke2/rke2.yaml
ENV KUBECONFIG="/etc/rancher/rke2/rke2.yaml"
# for crictl
ENV CONTAINER_RUNTIME_ENDPOINT="unix:///run/k3s/containerd/containerd.sock"
# for ctr
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ RUN apk --no-cache add \

# Dapper/Drone/CI environment
FROM rancher/hardened-build-base:v1.21.5b2 AS dapper
ENV DAPPER_ENV GODEBUG REPO TAG GITHUB_ACTION_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DOCKER_BUILDKIT DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY
ARG DAPPER_HOST_ARCH
ENV ARCH $DAPPER_HOST_ARCH
ENV DAPPER_OUTPUT ./dist ./bin ./build
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_TARGET dapper
ENV DAPPER_RUN_ARGS "--privileged --network host -v /tmp:/tmp -v rke2-pkg:/go/pkg -v rke2-cache:/root/.cache/go-build"
ENV ARCH="$DAPPER_HOST_ARCH"
ENV DAPPER_ENV="GODEBUG REPO TAG GITHUB_ACTION_TAG PAT_USERNAME PAT_TOKEN KUBERNETES_VERSION DRONE_BUILD_EVENT IMAGE_NAME AWS_SECRET_ACCESS_KEY AWS_ACCESS_KEY_ID ENABLE_REGISTRY"
ENV DAPPER_OUTPUT="./dist ./bin ./build"
ENV DAPPER_DOCKER_SOCKET="true"
ENV DAPPER_TARGET="dapper"
ENV DAPPER_RUN_ARGS="--privileged --network host -v /home/runner/.docker:/root/.docker -v /tmp:/tmp -v rke2-pkg:/go/pkg -v rke2-cache:/root/.cache/go-build"
RUN apk update
RUN set -x && \
apk add --no-cache \
Expand Down
8 changes: 6 additions & 2 deletions scripts/build-image-runtime
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ cd $(dirname $0)/..

source ./scripts/version.sh

DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} docker image build \
docker buildx ls

docker buildx build \
--load \
--build-arg TAG=${VERSION} \
--build-arg KUBERNETES_VERSION=${KUBERNETES_VERSION} \
--build-arg MAJOR=${VERSION_MAJOR} \
Expand All @@ -19,7 +22,8 @@ DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} docker image build \
.

if [ "${GOARCH}" != "s390x" ] && [ "${GOARCH}" != "arm64" ]; then
DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} docker image build \
docker buildx build \
--load \
--build-arg TAG=${VERSION} \
--build-arg KUBERNETES_VERSION=${KUBERNETES_VERSION} \
--build-arg MAJOR=${VERSION_MAJOR} \
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-image-test
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ if [ "${GOARCH}" == "s390x" ] || [ "${GOARCH}" == "arm64" ]; then
exit 0
fi

DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} docker image build \
docker buildx build \
--load \
--build-arg TAG=${VERSION} \
--build-arg KUBERNETES_VERSION=${KUBERNETES_VERSION} \
--build-arg CACHEBUST="$(date +%s%N)" \
Expand Down
2 changes: 1 addition & 1 deletion scripts/dev-shell-build
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ if [ ! -d build/images ]; then
fi

# build the dev shell image
DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} docker image build -t ${PROG}-dev --target shell .
docker buildx build --load -t ${PROG}-dev --target shell .

0 comments on commit da07df0

Please sign in to comment.