Skip to content

Commit 08a92b2

Browse files
committed
ci: fix Docker build - upload binary as artifact, use COPY instead of curl from draft release
1 parent 676e723 commit 08a92b2

3 files changed

Lines changed: 37 additions & 7 deletions

File tree

.github/workflows/build-artifacts.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ jobs:
5656
- name: Package release
5757
run: tar czf redlib-aarch64-unknown-linux-musl.tar.gz -C target/aarch64-unknown-linux-musl/release/ redlib
5858

59+
- name: Upload binary as workflow artifact
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: redlib-aarch64-unknown-linux-musl
63+
path: target/aarch64-unknown-linux-musl/release/redlib
64+
retention-days: 1
65+
5966
- name: Upload release
6067
uses: softprops/action-gh-release@v2
6168
with:

.github/workflows/main-docker.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,24 @@ jobs:
1818
- name: Checkout
1919
uses: actions/checkout@v4
2020

21+
- name: Download binary artifact from Release Build
22+
uses: actions/download-artifact@v4
23+
with:
24+
name: redlib-aarch64-unknown-linux-musl
25+
path: docker-bin/
26+
run-id: ${{ github.event.workflow_run.id }}
27+
github-token: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Make binary executable
30+
run: chmod +x docker-bin/redlib
31+
2132
- name: Docker meta
2233
id: meta
2334
uses: docker/metadata-action@v5
2435
with:
2536
images: ${{ env.REGISTRY_IMAGE }}
2637
tags: |
27-
type=sha
38+
type=sha,prefix=sha-,format=short,event=branch
2839
type=raw,value=latest,enable={{is_default_branch}}
2940
3041
- name: Set up Docker Buildx
@@ -45,15 +56,12 @@ jobs:
4556
push: true
4657
tags: ${{ steps.meta.outputs.tags }}
4758
labels: ${{ steps.meta.outputs.labels }}
48-
file: Dockerfile
49-
build-args: |
50-
TARGET=aarch64-unknown-linux-musl
51-
GITHUB_REPOSITORY=${{ github.repository }}
59+
file: Dockerfile.prebuilt
5260

53-
- name: Print image tag
61+
- name: Print image tags
5462
run: |
5563
echo "## Docker Image" >> $GITHUB_STEP_SUMMARY
5664
echo '```' >> $GITHUB_STEP_SUMMARY
5765
echo "docker pull ${{ env.REGISTRY_IMAGE }}:latest" >> $GITHUB_STEP_SUMMARY
58-
echo "docker pull ${{ env.REGISTRY_IMAGE }}:sha-$(echo '${{ github.sha }}' | cut -c1-7)" >> $GITHUB_STEP_SUMMARY
66+
echo "docker pull ${{ env.REGISTRY_IMAGE }}:sha-$(echo '${{ github.event.workflow_run.head_sha }}' | cut -c1-7)" >> $GITHUB_STEP_SUMMARY
5967
echo '```' >> $GITHUB_STEP_SUMMARY

Dockerfile.prebuilt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM alpine:3.19
2+
3+
# Binary is copied from the workflow artifact (docker-bin/redlib)
4+
COPY docker-bin/redlib /usr/local/bin/redlib
5+
6+
RUN adduser --home /nonexistent --no-create-home --disabled-password redlib
7+
USER redlib
8+
9+
# Tell Docker to expose port 8080
10+
EXPOSE 8080
11+
12+
# Run a healthcheck every minute to make sure redlib is functional
13+
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider -q http://localhost:8080/settings || exit 1
14+
15+
CMD ["redlib"]

0 commit comments

Comments
 (0)