Skip to content

Commit 52aaa34

Browse files
committed
build: improve build time
Signed-off-by: Alessandro Yuichi Okimoto <yuichijpn@gmail.com>
1 parent 9641a42 commit 52aaa34

2 files changed

Lines changed: 96 additions & 26 deletions

File tree

.github/.devcontainer/Dockerfile

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,48 @@ ENV LANG="C.UTF-8" \
77
SHELL=/bin/bash \
88
DOCKER_BUILDKIT=1
99

10-
# Install all packages in a single RUN command to reduce layers
10+
# Install packages in optimized order for better layer caching
1111
RUN apt-get update \
1212
&& apt-get upgrade -y \
1313
&& apt-get install -y --no-install-recommends \
14-
# Essential build tools
14+
# Core essentials (changes rarely)
15+
ca-certificates \
16+
curl \
17+
git \
18+
# Build tools (changes rarely)
1519
make \
1620
build-essential \
1721
cmake \
18-
curl \
19-
git \
22+
# File utilities
2023
unzip \
2124
zip \
2225
rsync \
23-
jq \
2426
xz-utils \
25-
# Database drivers (only what's actually needed)
27+
&& apt-get clean \
28+
&& rm -rf /var/lib/apt/lists/*
29+
30+
# Install development packages in separate layer
31+
RUN apt-get update && apt-get install -y --no-install-recommends \
32+
# Development tools
33+
jq \
34+
vim \
35+
protobuf-compiler \
36+
python3-dev \
37+
python3-pip \
38+
# Database drivers
2639
libpq-dev \
2740
default-libmysqlclient-dev \
2841
sqlite3 \
2942
libsqlite3-dev \
30-
# Development tools
31-
python3-dev \
32-
python3-pip \
33-
vim \
34-
protobuf-compiler \
35-
# Essential libraries
43+
# System libraries
3644
libssl-dev \
3745
libgcc1 \
3846
libstdc++6 \
3947
zlib1g \
4048
libuuid1 \
4149
uuid-dev \
4250
&& apt-get autoremove -y \
43-
&& apt-get clean -y \
51+
&& apt-get clean \
4452
&& rm -rf /var/lib/apt/lists/* \
4553
# Move first run notice to right spot
4654
&& mkdir -p "/usr/local/etc/vscode-dev-containers/" \

.github/workflows/devcontainer-image-build.yaml

Lines changed: 75 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,49 @@ on:
99
- ".github/.devcontainer/**"
1010

1111
jobs:
12-
build-and-push:
12+
# Build separate architectures in parallel for speed
13+
build-amd64:
1314
runs-on: ubuntu-latest
1415
steps:
1516
- name: Checkout (GitHub)
1617
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1718

18-
- name: Set up QEMU for multi-architecture builds
19+
- name: Setup Docker buildx
20+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
21+
with:
22+
use: true
23+
24+
- name: Login to GitHub Container Registry
25+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.repository_owner }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Build and push AMD64 image
32+
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
33+
with:
34+
context: .github/.devcontainer
35+
platforms: linux/amd64
36+
push: true
37+
tags: ghcr.io/bucketeer-io/bucketeer-devcontainer:amd64-${{ github.sha }}
38+
cache-from: type=gha,scope=amd64
39+
cache-to: type=gha,mode=max,scope=amd64
40+
build-args: |
41+
BUILDKIT_INLINE_CACHE=1
42+
43+
build-arm64:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout (GitHub)
47+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
48+
49+
- name: Set up QEMU for ARM64 builds
1950
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
2051
with:
21-
platforms: linux/amd64,linux/arm64
52+
platforms: linux/arm64
2253

23-
- name: Setup Docker buildx for multi-architecture builds
54+
- name: Setup Docker buildx
2455
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
2556
with:
2657
use: true
@@ -32,13 +63,44 @@ jobs:
3263
username: ${{ github.repository_owner }}
3364
password: ${{ secrets.GITHUB_TOKEN }}
3465

35-
- name: Build and release devcontainer Multi-Platform
36-
uses: devcontainers/ci@8bf61b26e9c3a98f69cb6ce2f88d24ff59b785c6 # v0.3
37-
env:
38-
BUILDX_NO_DEFAULT_ATTESTATIONS: true
66+
- name: Build and push ARM64 image
67+
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
3968
with:
40-
imageName: ghcr.io/bucketeer-io/bucketeer-devcontainer
41-
cacheFrom: ghcr.io/bucketeer-io/bucketeer-devcontainer
42-
platform: linux/amd64,linux/arm64
43-
subFolder: .github
44-
push: always
69+
context: .github/.devcontainer
70+
platforms: linux/arm64
71+
push: true
72+
tags: ghcr.io/bucketeer-io/bucketeer-devcontainer:arm64-${{ github.sha }}
73+
cache-from: type=gha,scope=arm64
74+
cache-to: type=gha,mode=max,scope=arm64
75+
build-args: |
76+
BUILDKIT_INLINE_CACHE=1
77+
78+
# Create multi-arch manifest that combines both architectures
79+
create-manifest:
80+
runs-on: ubuntu-latest
81+
needs: [build-amd64, build-arm64]
82+
steps:
83+
- name: Login to GitHub Container Registry
84+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
85+
with:
86+
registry: ghcr.io
87+
username: ${{ github.repository_owner }}
88+
password: ${{ secrets.GITHUB_TOKEN }}
89+
90+
- name: Create and push multi-arch manifest
91+
run: |
92+
# Create manifest list that includes both architectures
93+
docker manifest create \
94+
ghcr.io/bucketeer-io/bucketeer-devcontainer:latest \
95+
--amend ghcr.io/bucketeer-io/bucketeer-devcontainer:amd64-${{ github.sha }} \
96+
--amend ghcr.io/bucketeer-io/bucketeer-devcontainer:arm64-${{ github.sha }}
97+
98+
# Also create SHA-specific manifest (for debugging)
99+
docker manifest create \
100+
ghcr.io/bucketeer-io/bucketeer-devcontainer:${{ github.sha }} \
101+
--amend ghcr.io/bucketeer-io/bucketeer-devcontainer:amd64-${{ github.sha }} \
102+
--amend ghcr.io/bucketeer-io/bucketeer-devcontainer:arm64-${{ github.sha }}
103+
104+
# Push manifests
105+
docker manifest push ghcr.io/bucketeer-io/bucketeer-devcontainer:latest
106+
docker manifest push ghcr.io/bucketeer-io/bucketeer-devcontainer:${{ github.sha }}

0 commit comments

Comments
 (0)