Skip to content

Commit 715706f

Browse files
committed
Add caching
uses qemu emulator with arm64 default local
1 parent d0e1c3b commit 715706f

4 files changed

Lines changed: 29 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
permissions:
1717
contents: read
1818
packages: write
19-
2019
steps:
2120
- name: Checkout repository
2221
uses: actions/checkout@v4
@@ -36,6 +35,11 @@ jobs:
3635
version: 3.x
3736
repo-token: ${{ secrets.GITHUB_TOKEN }}
3837

38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@v3
40+
with:
41+
platforms: arm64
42+
3943
- name: Set up Docker Buildx
4044
uses: docker/setup-buildx-action@v3
4145

@@ -48,4 +52,6 @@ jobs:
4852

4953
- name: Build and push Docker image
5054
run: |
51-
task build IS_LOCAL=false VERSION=${{ env.VERSION }}
55+
task build IS_LOCAL=false VERSION="$VERSION" \
56+
CACHE_FROM="type=gha,scope=wasi-builder" \
57+
CACHE_TO="type=gha,scope=wasi-builder,mode=max"

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ ARG WKG_VERSION
1212
ENV CARGO_HOME=/usr/local/cargo \
1313
RUSTUP_HOME=/usr/local/rustup \
1414
PATH=/usr/local/cargo/bin:/usr/local/rustup/bin:$PATH \
15-
CARGO_TERM_COLOR=never
15+
CARGO_TERM_COLOR=never \
16+
UMASK=022
1617

1718
RUN apt-get update \
1819
&& apt-get install -y --no-install-recommends \
@@ -31,9 +32,6 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
3132
&& cargo install --locked wasm-tools@${WASM_TOOLS_VERSION} \
3233
&& cargo install --locked wkg@${WKG_VERSION}
3334

34-
# Set umask for reproducible file permissions
35-
RUN umask 022
36-
3735
WORKDIR /docker
3836
COPY entrypoint.sh /usr/local/bin/entrypoint
3937
RUN chmod +x /usr/local/bin/entrypoint

Taskfile.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ tasks:
2727
msg: "This task can only run on Linux (current OS: {{OS}})"
2828
vars:
2929
IS_LOCAL: '{{.IS_LOCAL | default "true"}}'
30-
VERSION: '{{.VERSION | default "latest"}}'
30+
VERSION: '{{.VERSION | default "local"}}'
31+
CACHE_FROM: '{{.CACHE_FROM | default ""}}'
32+
CACHE_TO: '{{.CACHE_TO | default ""}}'
3133
cmds:
3234
- |
3335
# Check if version is a git hash (7 characters, alphanumeric)
@@ -49,13 +51,25 @@ tasks:
4951
PUSH_FLAG="--push"
5052
fi
5153
54+
CACHE_FROM_FLAG=""
55+
if [ -n "{{.CACHE_FROM}}" ]; then
56+
CACHE_FROM_FLAG="--cache-from {{.CACHE_FROM}}"
57+
fi
58+
59+
CACHE_TO_FLAG=""
60+
if [ -n "{{.CACHE_TO}}" ]; then
61+
CACHE_TO_FLAG="--cache-to {{.CACHE_TO}}"
62+
fi
63+
5264
docker buildx build \
5365
$PLATFORM_FLAG \
5466
$TAGS \
5567
--build-arg RUST_VERSION={{.RUST_VERSION}} \
5668
--build-arg CARGO_COMPONENT_VERSION={{.CARGO_COMPONENT_VERSION}} \
5769
--build-arg WASM_TOOLS_VERSION={{.WASM_TOOLS_VERSION}} \
5870
--build-arg WKG_VERSION={{.WKG_VERSION}} \
71+
$CACHE_FROM_FLAG \
72+
$CACHE_TO_FLAG \
5973
$LOAD_FLAG \
6074
$PUSH_FLAG \
6175
-f {{.DOCKERFILE}} docker
@@ -74,7 +88,7 @@ tasks:
7488
test:
7589
desc: Test the built Docker image
7690
vars:
77-
VERSION: '{{.version | default "latest"}}'
91+
VERSION: '{{.version | default "local"}}'
7892
TEST_DIR: /tmp/wasi-test
7993
cmds:
8094
- task: test:setup

docker/entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ set -euo pipefail
55
export LC_ALL=C
66
export LANG=C
77

8+
# Ensure deterministic file permissions inside the container
9+
umask "${UMASK:-022}"
10+
811
# Production-ready WASI component builder
912
# Exit codes:
1013
# 1 - Usage error

0 commit comments

Comments
 (0)