File tree Expand file tree Collapse file tree 2 files changed +25
-12
lines changed
Expand file tree Collapse file tree 2 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -33,25 +33,24 @@ jobs:
3333 if : ${{ github.ref_type == 'tag' }}
3434 run : sed -i 's/^version = ".*"$/version = "${{ steps.meta.outputs.version }}"/' Cargo.toml
3535
36+ - name : Login to GHCR
37+ uses : docker/login-action@v3
38+ with :
39+ registry : ghcr.io/diamondlightsource
40+ username : ${{ github.actor }}
41+ password : ${{ secrets.GITHUB_TOKEN }}
42+
3643 - name : Build image
3744 uses : docker/build-push-action@v6
3845 env :
3946 DOCKER_BUILD_RECORD_UPLOAD : false
4047 with :
4148 context : .
42- cache-from : type=gha
43- cache-to : type=gha
44- tags : ${{ steps.meta.outputs.tags }}
49+ cache-from : type=registry,ref=ghcr.io/diamondlightsource/numtracker:buildcache
50+ cache-to : type=registry,ref=ghcr.io/diamondlightsource/numtracker:buildcache,mode=max
51+ tags : numtracker-build-cache
4552 load : true
4653
47- - name : Login to GHCR
48- if : ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
49- uses : docker/login-action@v3
50- with :
51- registry : ghcr.io/${{ github.repository_owner }}
52- username : ${{ github.actor }}
53- password : ${{ secrets.GITHUB_TOKEN }}
54-
5554 - name : Publish image
5655 uses : docker/build-push-action@v6
5756 env :
Original file line number Diff line number Diff line change @@ -7,15 +7,29 @@ RUN rustup target add x86_64-unknown-linux-musl && \
77
88WORKDIR /build
99
10+ # Jump through hoops here to improve the caching performance.
11+ # As each command creates a new layer that can be re-used as long as nothing
12+ # has changed, maximise the amount of work done before the frequently updated
13+ # files (.git and src) are included
14+
15+ # Create an empty project
16+ RUN cargo init --name empty-build-init
17+
18+ # Copy the cargo config but no source
1019COPY ./Cargo.toml ./Cargo.toml
1120COPY ./Cargo.lock ./Cargo.lock
21+
22+ # Build the empty project with all the dependencies
23+ RUN cargo build --release --target x86_64-unknown-linux-musl
24+
25+ # Copy the rest of the project in and build again
1226COPY ./build.rs ./build.rs
1327COPY ./.env ./.env
14- COPY ./src ./src
1528COPY ./.sqlx ./.sqlx
1629COPY ./migrations ./migrations
1730COPY ./queries ./queries
1831COPY ./static ./static
32+ COPY ./src ./src
1933# Copy the git directory purely so that the commit information can be included
2034# build details provided by the 'built' library. See #99
2135COPY ./.git ./.git
You can’t perform that action at this time.
0 commit comments