Skip to content

Commit e01a2e9

Browse files
committed
bump actions
show sccache stats update cache from/to config try to optimize dockerfile fix dockerfile fix chef command try to use sccache directory of the gh runner enable debug logs for sccache use build context to mount runner sccache to container sccache fix typo update sccache dir update target destination test test test test test test debug revert dockerfile changes try to cache manually change cache dir Trigger pipeline: test caching remove sccache dir Trigger pipeline: test caching remove uneeded args remove mozilla-actions/sccache-action, it doesn't work anyway Trigger pipeline: test caching docker layers manually set a better cache invalidation policy use cargo.lock for cache key better than toml files Trigger pipeline: local cache should work fix growing cache size issue Trigger pipeline: test after fixing growing cache size try to inject sccache into docker builds change key for docker caching debug sccache add sccache just command debug sccache env vars update rust wrapper env var remove sccache debug logs Trigger pipeline: test latest state include dev-tools dockerfile in creating cache key use cache map Trigger pipeline: test latest state try gha cache after letting gha set env vars automatically Trigger pipeline: test gha cache clean up after gha worked and try warp build cache Trigger pipeline: test gha warpbuild cache
1 parent 373979b commit e01a2e9

File tree

3 files changed

+38
-24
lines changed

3 files changed

+38
-24
lines changed

.github/workflows/binaries.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ jobs:
194194
EOF
195195
196196
- name: Build and push multiplatform image
197-
uses: docker/build-push-action@v5
197+
uses: docker/build-push-action@v6
198198
with:
199199
context: .
200200
push: true

.github/workflows/docker.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,22 @@ jobs:
6868
driver-opts: |
6969
network=host
7070
71-
- name: Run sccache-cache
72-
uses: mozilla-actions/[email protected]
71+
- name: Cache sccache
72+
uses: actions/cache@v4
73+
with:
74+
path: sccache-cache
75+
key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock') }}
76+
77+
- name: Inject sccache-cache into Docker
78+
uses: reproducible-containers/buildkit-cache-dance@v3
79+
with:
80+
cache-map: |
81+
{
82+
"sccache-cache": "/var/cache/sccache"
83+
}
84+
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
7385

86+
7487
- name: Log into GitHub container registry
7588
uses: docker/login-action@v3
7689
with:
@@ -107,7 +120,7 @@ jobs:
107120
108121
- name: Build${{inputs.uploadImageAsTarball != true && ' and push ' || ' '}}Docker image
109122
id: build
110-
uses: docker/build-push-action@v5
123+
uses: docker/build-push-action@v6
111124
with:
112125
context: .
113126
file: "docker/Dockerfile"
@@ -119,13 +132,11 @@ jobs:
119132
network: host
120133
build-args: |
121134
CARGO_PROFILE_RELEASE_DEBUG=${{ inputs.debug }}
122-
ACTIONS_CACHE_URL=http://127.0.0.1:49160/
123-
ACTIONS_RUNTIME_TOKEN
124-
SCCACHE_GHA_ENABLED=true
125135
RESTATE_FEATURES=${{ inputs.features || '' }}
126-
cache-from: type=gha,scope=${{ github.workflow }},url=http://127.0.0.1:49160/
127-
cache-to: type=gha,mode=max,scope=${{ github.workflow }},url=http://127.0.0.1:49160/
128-
136+
SCCACHE_DIR=~/.cache/sccache
137+
cache-from: type=gha,url=http://127.0.0.1:49160/
138+
cache-to: type=gha,url=http://127.0.0.1:49160/,mode=max
139+
129140
- name: Save docker image as tar
130141
if: ${{ inputs.uploadImageAsTarball }}
131142
run: |
@@ -144,7 +155,7 @@ jobs:
144155
# This won't actually build again, it'll just use cache
145156
- name: Push Docker image
146157
if: ${{ inputs.uploadImageAsTarball && github.ref == 'refs/heads/main' }}
147-
uses: docker/build-push-action@v5
158+
uses: docker/build-push-action@v6
148159
with:
149160
context: .
150161
file: "docker/Dockerfile"
@@ -157,9 +168,8 @@ jobs:
157168
network: host
158169
build-args: |
159170
CARGO_PROFILE_RELEASE_DEBUG=${{ inputs.debug }}
160-
ACTIONS_CACHE_URL=http://127.0.0.1:49160/
161-
ACTIONS_RUNTIME_TOKEN
162-
SCCACHE_GHA_ENABLED=true
163171
RESTATE_FEATURES=${{ inputs.features || '' }}
164-
cache-from: type=gha,scope=${{ github.workflow }},url=http://127.0.0.1:49160/
165-
cache-to: type=gha,mode=max,scope=${{ github.workflow }},url=http://127.0.0.1:49160/
172+
SCCACHE_DIR=/sccache-cache
173+
cache-from: type=gha,url=http://127.0.0.1:49160/
174+
cache-to: type=gha,url=http://127.0.0.1:49160/,mode=max
175+

docker/Dockerfile

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,23 @@ ARG SCCACHE_SERVER_PORT=4227
2626
FROM base-$TARGETARCH AS builder
2727
ARG SCCACHE_SERVER_PORT
2828
ARG TARGETARCH
29-
# https://github.com/mozilla/sccache/blob/main/docs/GHA.md
30-
ARG ACTIONS_CACHE_URL=''
31-
ARG ACTIONS_RUNTIME_TOKEN=''
32-
ARG SCCACHE_GHA_ENABLED=''
29+
30+
ENV RUSTC_WRAPPER=/usr/bin/sccache
31+
ENV SCCACHE_DIR=/var/cache/sccache
32+
3333
# Overrides the behaviour of the release profile re including debug symbols, which in our repo is not to include them.
3434
# Should be set to 'false' or 'true'. See https://doc.rust-lang.org/cargo/reference/environment-variables.html
3535
ARG CARGO_PROFILE_RELEASE_DEBUG=false
3636
ARG RESTATE_FEATURES=''
37-
# Caching layer if nothing has changed
38-
# Only build restate binary to avoid compiling unneeded crates
37+
3938
RUN just arch=$TARGETARCH libc=gnu features=$RESTATE_FEATURES chef-cook --release --bin restate-server
39+
4040
COPY . .
41-
RUN just arch=$TARGETARCH libc=gnu features=$RESTATE_FEATURES build --release --bin restate-server && \
41+
# Mount the sccache directory as a cache to leverage sccache during build
42+
# Caching layer if nothing has changed
43+
# Use sccache during the main build
44+
RUN --mount=type=cache,target=/var/cache/sccache \
45+
just arch=$TARGETARCH libc=gnu features=$RESTATE_FEATURES build --release --bin restate-server && \
4246
just notice-file && \
4347
mv target/$(just arch=$TARGETARCH libc=gnu print-target)/release/restate-server target/restate-server
4448

@@ -52,4 +56,4 @@ COPY --from=builder /etc/ssl /etc/ssl
5256
# useful for health checks
5357
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
5458
WORKDIR /
55-
ENTRYPOINT ["/usr/local/bin/restate-server"]
59+
ENTRYPOINT ["/usr/local/bin/restate-server"]

0 commit comments

Comments
 (0)