diff options
| author | Fuwn <[email protected]> | 2026-02-14 21:53:11 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-14 21:53:24 -0800 |
| commit | d277dbfc6f2ca5363928ee9ad41e3460a834242f (patch) | |
| tree | d54b6611a25ea083a34b1bc2403b1fa70417b0c7 | |
| parent | fix(blog): Remove extra whitespace on category pages without descriptions (diff) | |
| download | locus-d277dbfc6f2ca5363928ee9ad41e3460a834242f.tar.xz locus-d277dbfc6f2ca5363928ee9ad41e3460a834242f.zip | |
build(container): Add justfile recipe to build and push latest/date tags to GitHub and GitLab
| -rw-r--r-- | .dockerignore (renamed from .earthlyignore) | 4 | ||||
| -rw-r--r-- | Dockerfile | 50 | ||||
| -rw-r--r-- | Earthfile | 57 | ||||
| -rw-r--r-- | justfile | 27 |
4 files changed, 80 insertions, 58 deletions
diff --git a/.earthlyignore b/.dockerignore index a873cd5..c785159 100644 --- a/.earthlyignore +++ b/.dockerignore @@ -5,5 +5,7 @@ !content/ !src/ !build.rs -!Cargo.* +!Cargo.toml +!Cargo.lock !yarte.toml +!Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0d55f14 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,50 @@ +# syntax=docker/dockerfile:1.7 + +ARG RUSTC_VERSION=nightly-2025-01-21 + +FROM clux/muslrust:${RUSTC_VERSION} AS build + +RUN rustup component add rust-src + +WORKDIR /source + +RUN cargo new locus + +WORKDIR /source/locus + +COPY amenadiel/ ./amenadiel/ +COPY Cargo.toml Cargo.lock ./ + +RUN --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cargo/git \ + cargo build --release -Zbuild-std + +COPY .git ./.git +COPY content ./content +COPY src ./src +COPY build.rs ./build.rs +COPY yarte.toml ./yarte.toml + +RUN find ./content -name "*.DS_Store" -delete +RUN --mount=type=cache,target=/root/.cargo/registry \ + --mount=type=cache,target=/root/.cargo/git \ + cargo build --release --bin locus +RUN set -eux; \ + bin_path="$(find /source/locus/target -type f -path '*/release/locus' | head -n 1)"; \ + test -n "${bin_path}"; \ + strip -s "${bin_path}"; \ + cp "${bin_path}" /source/locus/locus +RUN strip -s /source/locus/locus +RUN mkdir /new_tmp + +FROM scratch AS runtime + +WORKDIR /locus + +COPY --from=build /source/locus/locus ./locus +COPY --from=build /source/locus/content ./content +COPY --from=build /new_tmp /tmp + +EXPOSE 1965 + +ENTRYPOINT ["./locus"] diff --git a/Earthfile b/Earthfile deleted file mode 100644 index bcf338b..0000000 --- a/Earthfile +++ /dev/null @@ -1,57 +0,0 @@ -VERSION 0.7 - -docker: - ARG tag=latest - - FROM scratch - - WORKDIR /locus - - COPY +build/locus . - COPY +build/content ./content - # https://www.reddit.com/r/docker/comments/8y2zyx/how_to_add_a_empty_directory_to_a_scratch_image/e27oumn/ - COPY +build/new_tmp /tmp - - EXPOSE 1965 - - ENTRYPOINT ["./locus"] - - SAVE IMAGE --push ghcr.io/gemrest/locus:$tag - -deps: - ARG rustc="nightly-2025-01-21" - - FROM clux/muslrust:${rustc} - - RUN rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu - -build: - FROM +deps - - WORKDIR /source - - RUN cargo new locus - - WORKDIR /source/locus - - COPY amenadiel/ ./amenadiel/ - COPY Cargo.* . - - RUN cargo build --release -Zbuild-std - - COPY .git .git - COPY content content - COPY src src - COPY build.rs build.rs - COPY yarte.toml yarte.toml - - RUN find ./content -name "*.DS_Store" -delete - RUN cargo build --release --bin locus - RUN strip -s /source/locus/target/x86_64-unknown-linux-musl/release/locus - RUN mv /source/locus/target/x86_64-unknown-linux-musl/release/locus . - RUN strip -s /source/locus/locus - RUN mkdir /new_tmp - - SAVE ARTIFACT /source/locus/locus - SAVE ARTIFACT /source/locus/content - SAVE ARTIFACT /new_tmp diff --git a/justfile b/justfile new file mode 100644 index 0000000..8f39114 --- /dev/null +++ b/justfile @@ -0,0 +1,27 @@ +set shell := ["bash", "-eu", "-o", "pipefail", "-c"] + +ghcr_repo := "ghcr.io/gemrest/locus" +gitlab_repo := "registry.gitlab.com/gemrest/locus" + +default: + just --list + +# Build once, then push both `latest` and `YYYY-MM-DD` tags to both registries. +publish-images: + #!/usr/bin/env bash + + set -euo pipefail + + date_tag="$(date -u +%Y-%m-%d)" + + docker build -f Dockerfile -t locus:build . + + for registry in {{ghcr_repo}} {{gitlab_repo}}; do + docker tag locus:build "$registry:latest" + docker tag locus:build "$registry:$date_tag" + done + + docker push "{{ghcr_repo}}:latest" + docker push "{{ghcr_repo}}:$date_tag" + docker push "{{gitlab_repo}}:latest" + docker push "{{gitlab_repo}}:$date_tag" |