diff options
| author | Hazel Atkinson <yellowsink@riseup.net> | 2025-04-09 17:42:05 +0100 |
|---|---|---|
| committer | Hazel Atkinson <yellowsink@riseup.net> | 2025-04-09 17:45:43 +0100 |
| commit | 0263a68d331db9b6142ba972d6a24b33e6500781 (patch) | |
| tree | 51b7d73d16778c67c8ec11a0785bd9e3dcc9330d | |
| parent | 62530eabfb8a7d278d570a8ee5375e6c67717fbb (diff) | |
| download | containerspy-0263a68d331db9b6142ba972d6a24b33e6500781.tar.gz containerspy-0263a68d331db9b6142ba972d6a24b33e6500781.tar.bz2 containerspy-0263a68d331db9b6142ba972d6a24b33e6500781.zip | |
way more optimal dockerfile
| -rw-r--r-- | .github/workflows/publish.yml | 4 | ||||
| -rw-r--r-- | Dockerfile | 24 |
2 files changed, 21 insertions, 7 deletions
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6ab5170..007f913 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -58,4 +58,6 @@ jobs: file: ./Dockerfile push: true tags: ${{ env.DOCKER_IMAGE_TAGS }} - platforms: linux/amd64,linux/arm64,linux/arm/v7
\ No newline at end of file + platforms: linux/amd64,linux/arm64,linux/arm/v7 + cache-from: type=gha + cache-to: type=gha,mode=max
\ No newline at end of file @@ -1,16 +1,28 @@ -FROM rust:1.86-slim AS build-env +FROM rust:1.86-alpine3.21 AS build-env WORKDIR /build -# since this is just a build env, simply copy everything in, no need to be picky -COPY . . +# the rust container is literally incomplete lol +# https://stackoverflow.com/a/74309414 +RUN apk add --no-cache pcc-libs-dev musl-dev pkgconf -# this builds a release binary and leaves the binary in /usr/local/cargo/bin/myapp -RUN cargo install --path . +# for layer caching, first only build the deps, so that changes to literally anything else don't invalidate the cache +RUN mkdir src +RUN echo 'fn main() {}' > src/main.rs +COPY Cargo.toml Cargo.lock ./ +RUN cargo build --release + +# copy in the real source +RUN rm src/*.rs +COPY src src +COPY build.rs ./ + +# this builds a release binary +RUN cargo build --release FROM alpine:3.21 -COPY --from=build-env /usr/local/cargo/bin/containerspy /usr/bin/containerspy +COPY --from=build-env /build/target/release/containerspy /usr/bin/containerspy # for mounting config.json into RUN mkdir /etc/containerspy |
