Skip to content

Commit

Permalink
chore: Improve image build speed (#1919)
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Marquis <[email protected]>
  • Loading branch information
34fathombelow authored Apr 1, 2022
1 parent 40c22b3 commit beae624
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
26 changes: 11 additions & 15 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# - name: Cache Docker layers
# uses: actions/cache@v2
# with:
# path: /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-buildx-

- name: Docker meta (controller)
id: controller-meta
Expand Down Expand Up @@ -87,8 +87,6 @@ jobs:
platforms: ${{ steps.platform-matrix.outputs.platform-matrix }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.controller-meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Build and push (plugin-image)
uses: docker/build-push-action@v2
Expand All @@ -97,13 +95,11 @@ jobs:
platforms: ${{ steps.platform-matrix.outputs.platform-matrix }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.plugin-meta.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
# - name: Move cache
# run: |
# rm -rf /tmp/.buildx-cache
# mv /tmp/.buildx-cache-new /tmp/.buildx-cache
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Initial stage which pulls prepares build dependencies and CLI tooling we need for our final image
# Also used as the image in CI jobs so needs all dependencies
####################################################################################################
FROM golang:1.17.6 as builder
FROM --platform=$BUILDPLATFORM golang:1.17.6 as builder

RUN apt-get update && apt-get install -y \
wget \
Expand All @@ -24,7 +24,7 @@ RUN cd ${GOPATH}/src/dummy && \
####################################################################################################
# UI build stage
####################################################################################################
FROM docker.io/library/node:12.18.4 as argo-rollouts-ui
FROM --platform=$BUILDPLATFORM docker.io/library/node:12.18.4 as argo-rollouts-ui

WORKDIR /src
ADD ["ui/package.json", "ui/yarn.lock", "./"]
Expand All @@ -40,7 +40,7 @@ RUN NODE_ENV='production' yarn build
####################################################################################################
# Rollout Controller Build stage which performs the actual build of argo-rollouts binaries
####################################################################################################
FROM golang:1.17.6 as argo-rollouts-build
FROM --platform=$BUILDPLATFORM golang:1.17.6 as argo-rollouts-build

WORKDIR /go/src/github.com/argoproj/argo-rollouts

Expand All @@ -61,8 +61,9 @@ RUN touch ui/dist/node_modules.marker && \
touch ui/dist/app/index.html && \
find ui/dist

ARG TARGETOS TARGETARCH
ARG MAKE_TARGET="controller plugin plugin-linux plugin-darwin plugin-windows"
RUN make ${MAKE_TARGET}
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make ${MAKE_TARGET}

####################################################################################################
# Kubectl plugin image
Expand Down

0 comments on commit beae624

Please sign in to comment.