Skip to content

Commit

Permalink
tweak Dockerfile: cache dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
imikushin committed Jan 6, 2025
1 parent 174eb17 commit f70840b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.DS_Store
/.fleet
/.github
/.idea
/.run
/elf
/target
/tmp
Dockerfile
2 changes: 1 addition & 1 deletion .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Create and publish a Docker image

on:
push:
branches: ['release']
branches: ['release', 'stage']
tags: ['v*']

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
Expand Down
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/target
.DS_Store
/.idea
/elf/
/tmp/

/.run
/elf
/target
/tmp
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# syntax=docker/dockerfile:1-labs

FROM rust:alpine AS base
RUN apk add --no-cache musl-dev openssl-dev pkgconfig openssl-libs-static
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static pkgconfig
WORKDIR /app

FROM base AS builder
WORKDIR /app
COPY --exclude=./examples/** --parents ./**/Cargo.* ./rust-toolchain.toml ./
RUN mkdir -p ./src ./charms-data/src ./charms-sdk/src ./charms-spell-checker/src && \
touch -d '2000-01-01 00:00' src/main.rs src/lib.rs charms-data/src/lib.rs charms-sdk/src/lib.rs charms-spell-checker/src/lib.rs
RUN cargo build --release --locked --bin charms --keep-going || true
COPY . .
RUN --mount=type=cache,target=/app/target \
--mount=type=cache,from=base,source=/usr/local/rustup,target=/usr/local/rustup \
cargo install --locked --path .
RUN cargo install --locked --offline --path . --bin charms

FROM alpine AS runtime
COPY --from=builder /usr/local/cargo/bin/charms /usr/local/bin
Expand Down

0 comments on commit f70840b

Please sign in to comment.