Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
chore(ci): speed up docker build
Browse files Browse the repository at this point in the history
trying two things:
- speed up arm build by allowing cross-comp
- take a stab at caching builx layers
  • Loading branch information
lidel committed Apr 6, 2023
1 parent 1e844f7 commit 14cfa48
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- 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: Get tags
id: tags
run: |
Expand All @@ -54,3 +62,12 @@ jobs:
push: true
file: ./Dockerfile
tags: "${{ steps.tags.outputs.value }}"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache to limit growth
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM golang:1.20-bullseye AS builder
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.20-bullseye AS builder
MAINTAINER IPFS Stewards <[email protected]>

# This dockerfile builds and runs bifrost-gateway

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

ENV GOPATH /go
ENV SRC_PATH $GOPATH/src/github.com/ipfs/bifrost-gateway
ENV GO111MODULE on
Expand Down Expand Up @@ -34,11 +39,11 @@ RUN go mod download

COPY --chown=1000:users . $SRC_PATH
RUN git config --global --add safe.directory /go/src/github.com/ipfs/bifrost-gateway
RUN go install
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o $GOPATH/bin/bifrost-gateway


#------------------------------------------------------
FROM busybox:1-glibc
FROM --platform=${BUILDPLATFORM:-linux/amd64} busybox:1-glibc
MAINTAINER IPFS Stewards <[email protected]>

ENV GOPATH /go
Expand Down

0 comments on commit 14cfa48

Please sign in to comment.