mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
fix(ci): speed up docker build (#9800)
trying two things:
- speed up arm build by allowing cross-comp from go instead of slow QEMU
- take a stab at caching buildx layers, without infinite growth
This fix was laready applied in
14cfa48bed
and reduced build time from 20m to 3m.
This commit is contained in:
parent
c6a59c9cc1
commit
6f08cdedc0
17
.github/workflows/docker-image.yml
vendored
17
.github/workflows/docker-image.yml
vendored
@ -31,6 +31,14 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Get tags
|
||||
id: tags
|
||||
run: |
|
||||
@ -53,3 +61,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
Dockerfile
11
Dockerfile
@ -1,6 +1,11 @@
|
||||
FROM golang:1.19.1-buster
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19.1-buster
|
||||
LABEL maintainer="Steven Allen <steven@stebalien.com>"
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
ARG BUILDPLATFORM
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
|
||||
# Install deps
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libssl-dev \
|
||||
@ -24,7 +29,7 @@ ARG IPFS_PLUGINS
|
||||
# Also: fix getting HEAD commit hash via git rev-parse.
|
||||
RUN cd $SRC_DIR \
|
||||
&& mkdir -p .git/objects \
|
||||
&& GOFLAGS=-buildvcs=false make build GOTAGS=openssl IPFS_PLUGINS=$IPFS_PLUGINS
|
||||
&& GOOS=$TARGETOS GOARCH=$TARGETARCH GOFLAGS=-buildvcs=false make build GOTAGS=openssl IPFS_PLUGINS=$IPFS_PLUGINS
|
||||
|
||||
# Get su-exec, a very minimal tool for dropping privileges,
|
||||
# and tini, a very minimal init daemon for containers
|
||||
@ -46,7 +51,7 @@ RUN set -eux; \
|
||||
&& chmod +x tini
|
||||
|
||||
# Now comes the actual target image, which aims to be as small as possible.
|
||||
FROM busybox:1.31.1-glibc
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} busybox:1.31.1-glibc
|
||||
LABEL maintainer="Steven Allen <steven@stebalien.com>"
|
||||
|
||||
# Get the ipfs binary, entrypoint script, and TLS CAs from the build container.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user