Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ef3afe8
Add container image support with multi-arch builds
elasticdotventures Aug 4, 2025
86c962f
Address feedback from polarathene's review
elasticdotventures Aug 5, 2025
6b8e128
Remove unnecessary apk install since wget and tar are included in alpine
elasticdotventures Aug 5, 2025
a593fab
Update .github/workflows/container.yaml
elasticdotventures Aug 7, 2025
224544c
Update README.md
elasticdotventures Aug 7, 2025
89d3541
Improve container workflow tag handling based on @polarathene feedback
elasticdotventures Aug 7, 2025
ff8e6f4
Add ._b00t_.toml to gitignore
elasticdotventures Aug 7, 2025
c852393
Update .github/workflows/container.yaml
elasticdotventures Aug 8, 2025
9f8c939
Update Dockerfile
elasticdotventures Aug 8, 2025
7407512
Update .github/workflows/container.yaml
elasticdotventures Aug 8, 2025
9f605fd
Convert container workflow to use workflow_call pattern
elasticdotventures Aug 7, 2025
ce0e6d4
removed ._b00t_.toml from .gitignore
elasticdotventures Aug 11, 2025
173cbbe
Dockerfile
elasticdotventures Aug 11, 2025
c8e81ae
workflow changes by @polarathene
elasticdotventures Aug 11, 2025
5ba73ed
Update .github/workflows/container.yaml
elasticdotventures Aug 21, 2025
2d60cd1
Update .github/workflows/container.yaml
elasticdotventures Aug 21, 2025
024d275
Update Dockerfile
elasticdotventures Aug 21, 2025
30844eb
Update .github/workflows/container.yaml
elasticdotventures Aug 21, 2025
bf820ad
Update .github/workflows/container.yaml
elasticdotventures Aug 21, 2025
db30ade
Update .github/workflows/release.yaml
elasticdotventures Aug 21, 2025
7941449
Apply suggestion from @polarathene
elasticdotventures Aug 21, 2025
fc0b7d3
Apply suggestion from @polarathene
elasticdotventures Aug 21, 2025
4d25179
Merge branch 'master' into issue/1497
elasticdotventures Oct 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Container Image

on:

# Manual trigger via GH Actions page, runs this workflow from a selected tag or branch,
# which also affects the git clone for the `Dockerfile` used, and `github.ref_type` (branch / tag)
workflow_dispatch:
inputs:
version:
description: 'Version to build (e.g., 1.42.4)'
required: true
type: string

# `release.yaml` calls this workflow after it has published a new release and attached files.
# NOTE: As `release.yaml` is triggered via a tag being pushed, this workflow inherits
# that push event context (github.{event_name, event, ref_type, ref_name, ...})
workflow_call:
inputs:
version:
description: 'Version to build (e.g., 1.42.4)'
required: true
type: string

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4


- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare image metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# NOTE: The `semver` tag type below (with the default `flavor.latest=auto` action setting),
# will implicitly append a `latest` tag to publish:
# https://github.com/docker/metadata-action/issues/461#issuecomment-2680849083
tags: |
type=semver,pattern={{major}},value=${{ inputs.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ inputs.version }}
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{ inputs.version }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
JUST_VERSION=${{ inputs.version }}
11 changes: 11 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,14 @@ jobs:
github_token: ${{secrets.GITHUB_TOKEN}}
publish_branch: gh-pages
publish_dir: www

container:
uses: ./.github/workflows/container.yaml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No action required, just informative for those unaware.


For reference: This will run the container.yaml workflow associated to the commit of this workflows trigger (the tagged commit), just as release.yaml itself does.

  • For this project in particular and the way this container job is triggered, this isn't a concern since it's unlikely to have a release with an older Dockerfile checkout being used.
  • In other projects where the trigger isn't the latest commit on the default branch being tagged, but some other release series branch, you'd have to keep in mind the risk of divergence (note: there is a similar caveat with workflow_dispatch at container.yaml when selecting to run from a different ref instead of the default branch offered).
  • This can be worth being mindful of when workflow_run is involved, since it instead operates from the latest commit (head ref) at the default branch, regardless of the commit that the workflow it depends on was using (release.yaml in this case).

However if it was desirable to fix container.yaml or the Dockerfile as a CI fix in a commit that landed after the commit to be tagged for release, before that release was triggered via the maintainer pushing the tag... then it'd be useful to ensure this were adjusted.

That said, in other contexts doing so can be problematic when other branches are used such as a PR update for a workflow that is triggered by PRs, or breaking changes affecting other long-lived branches or forks (if neither patched workflows that weren't restricted to the default branch to trigger).

The alternative with a specific git ref would look like this (the owner + repo prefix is mandatory however and expressions cannot be used for the benefit of forks or copy/paste):

 container:
    uses: casey/just/.github/workflows/container.yaml@master

needs:
- package
- prerelease
# Avoid publishing images for pre-releases (NOTE: `value` is a string, not a boolean)
if: ${{ needs.prerelease.outputs.value == 'false' }}
with:
version: ${{ github.ref_name }}
secrets: inherit
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# syntax=docker/dockerfile:1

# NOTE: ARGs `BUILDPLATFORM` + `TARGETARCH` are implicitly defined by BuildKit:
# https://docs.docker.com/reference/dockerfile/#automatic-platform-args-in-the-global-scope
# NOTE: BuildKit supplied ARGs use convention amd64 / arm64 instead of the desired x86_64 / aarch64
# https://itsfoss.com/arm-aarch64-x86_64
#
# Map arch naming conventions from BuildKit to Rust (TARGETARCH => RUST_ARCH):
FROM --platform=${BUILDPLATFORM} alpine AS downloader-amd64
ARG RUST_ARCH=x86_64
FROM --platform=${BUILDPLATFORM} alpine AS downloader-arm64
ARG RUST_ARCH=aarch64

# Fetch the expected version of `just` via GH Releases:
FROM downloader-${TARGETARCH} AS downloader
SHELL ["/bin/ash", "-eux", "-o", "pipefail", "-c"]
# This ARG will be set via GitHub Actions during release builds
ARG JUST_VERSION
ARG RELEASE_URL="https://github.com/casey/just/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-${RUST_ARCH}-unknown-linux-musl.tar.gz"
RUN wget -O - "${RELEASE_URL}" \
| tar --directory /usr/local/bin --extract --gzip --no-same-owner just

# Use scratch for minimal final image - no OS, just the binary
# This results in a ~10MB image vs ~50MB+ with a full OS
FROM scratch
COPY --from=downloader /usr/local/bin/just /usr/local/bin/just

# Default to running just with help if no arguments provided
ENTRYPOINT ["just"]
CMD ["--help"]
Comment on lines +23 to +30

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming you agree with the prior Dockerfile comment on CMD + scratch, this will improve usability of the image directly at the expense of going from 5MB to 13MB (less in network overhead due to compression at the image registry), seems like a reasonable tradeoff:

Suggested change
# Use scratch for minimal final image - no OS, just the binary
# This results in a ~10MB image vs ~50MB+ with a full OS
FROM scratch
COPY --from=downloader /usr/local/bin/just /usr/local/bin/just
# Default to running just with help if no arguments provided
ENTRYPOINT ["just"]
CMD ["--help"]
ENTRYPOINT ["just"]

Otherwise update the README to inform users about the image not being intended for direct usage, so they don't burden the maintainer with support requests.

Comment on lines +23 to +30
Copy link

@polarathene polarathene Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As previously detailed in feedback.


5MB => 13MB increase, but the image can be used directly.

Suggested change
# Use scratch for minimal final image - no OS, just the binary
# This results in a ~10MB image vs ~50MB+ with a full OS
FROM scratch
COPY --from=downloader /usr/local/bin/just /usr/local/bin/just
# Default to running just with help if no arguments provided
ENTRYPOINT ["just"]
CMD ["--help"]
FROM alpine
COPY --from=downloader /usr/local/bin/just /usr/local/bin/just
ENTRYPOINT ["just"]

No need to update README to mention the lack of a shell if adopting this change.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4682,4 +4682,12 @@ your computational endeavors!

😸

## Container Usage

Copy `just` into your own `Dockerfile`:

```Dockerfile
COPY --link --from=ghcr.io/casey/just:latest /usr/local/bin/just /usr/local/bin/just
```

[🔼 Back to the top!](#just)