Prepared things for Docker
This commit is contained in:
1 parent
f2cefdd429
commit
577715bb40
7 files changed
+108
-17
No files matched your search
@@ -20,6 +20,12 @@ env:
|
||||
ZIG_VERSION: 0.17.0
|
||||
CARGO_TERM_COLOR: always
|
||||
CARGO_PROFILE_RELEASE_STRIP: symbols
|
||||
# The Docker image is the release binary on top of this base. Alpine rather
|
||||
# than distroless so there's a shell for `docker exec` and post-move hooks.
|
||||
BASE_IMAGE: alpine:3.24
|
||||
# crane builds and pushes the image without a Docker daemon. Pinned by hash.
|
||||
CRANE_VERSION: v0.22.1
|
||||
CRANE_SHA256: 0ab7a1d6932a213aed964ce97666c3077fe691c8606413674a8b3e0b9ec4cda0
|
||||
|
||||
jobs:
|
||||
release:
|
||||
@@ -86,3 +92,45 @@ jobs:
|
||||
run: >-
|
||||
node .github/scripts/gitea-release.mjs "$GITHUB_REF_NAME" dist/release-notes.md
|
||||
"$ASSET" "$ASSET.sha256"
|
||||
|
||||
- name: Install crane
|
||||
run: |
|
||||
curl -fsSLo crane.tar.gz "https://github.com/google/go-containerregistry/releases/download/$CRANE_VERSION/go-containerregistry_Linux_x86_64.tar.gz"
|
||||
echo "$CRANE_SHA256 crane.tar.gz" | sha256sum -c -
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
tar -xzf crane.tar.gz -C "$HOME/.local/bin" crane
|
||||
rm crane.tar.gz
|
||||
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||
|
||||
# Pushes <gitea host>/<owner>/jellymove:<version>, plus :latest unless the
|
||||
# tag is a pre-release. The workflow's own token is tried first; if Gitea
|
||||
# refuses it, add REGISTRY_USER and REGISTRY_TOKEN (write:package) secrets.
|
||||
- name: Publish the Docker image
|
||||
env:
|
||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER || github.actor }}
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
registry="${GITHUB_SERVER_URL#*://}"
|
||||
registry="${registry%%/*}"
|
||||
image="$registry/$(echo "$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]')"
|
||||
version="${GITHUB_REF_NAME#v}"
|
||||
echo "$REGISTRY_TOKEN" | crane auth login "$registry" -u "$REGISTRY_USER" --password-stdin
|
||||
|
||||
mkdir -p dist/image/usr/local/bin
|
||||
install -m 755 "target/$TARGET/release/jellymove" dist/image/usr/local/bin/jellymove
|
||||
tar -C dist/image --owner=0 --group=0 --numeric-owner -cf dist/image.tar usr
|
||||
|
||||
crane append --platform linux/amd64 -b "$BASE_IMAGE" -f dist/image.tar -t "$image:$version"
|
||||
crane mutate "$image:$version" -t "$image:$version" \
|
||||
--entrypoint /usr/local/bin/jellymove --cmd run \
|
||||
--env JELLYMOVE_CONFIG=/config/jellymove.toml \
|
||||
--exposed-ports 8097/tcp --workdir / \
|
||||
--label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
|
||||
--label "org.opencontainers.image.version=$version" \
|
||||
--label "org.opencontainers.image.revision=$GITHUB_SHA"
|
||||
case "$GITHUB_REF_NAME" in
|
||||
*-*) echo "Pre-release: not moving :latest" ;;
|
||||
*) crane tag "$image:$version" latest ;;
|
||||
esac
|
||||
crane config "$image:$version"
|
||||
echo "Pushed $image:$version"
|
||||
Reference in new issue
Block a user