Skip to content

Commit

Permalink
ci: build docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Oct 9, 2023
1 parent 6aac2fb commit d6fe7e6
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/docker/Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM --platform=linux/amd64 alpine:latest

LABEL org.opencontainers.image.source=https://github.com/xJonathanLEI/starkli

COPY --chmod=744 ./starkli /usr/bin/

ENTRYPOINT [ "starkli" ]
7 changes: 7 additions & 0 deletions .github/workflows/docker/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM --platform=linux/arm64/v8 alpine:latest

LABEL org.opencontainers.image.source=https://github.com/xJonathanLEI/starkli

COPY --chmod=744 ./starkli /usr/bin/

ENTRYPOINT [ "starkli" ]
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,90 @@ jobs:
-H "Content-Type: application/octet-stream" \
--data-binary "@target/aarch64-linux-android/release/${ARTIFACT_NAME}"
release-docker-images:
name: "Build Docker image for ${{ matrix.tag }}"
runs-on: "ubuntu-latest"
needs:
# We don't really need all these, but we want to make sure all platforms build successfully
# before running this step, as this step makes Docker images public already.
- "crate-info"
- "release-non-apple"
- "release-apple"
- "release-android"

strategy:
matrix:
include:
- tag: "amd64"
artifact: "starkli-x86_64-unknown-linux-musl"
- tag: "arm64"
artifact: "starkli-aarch64-unknown-linux-musl"

steps:
- name: "Checkout source code"
uses: "actions/checkout@v3"

- name: "Login to Docker Hub"
uses: "docker/login-action@v2"
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"

- name: "Determine full Docker tag"
run: |
echo "DOCKER_TAG=starknet/starkli:${{ needs.crate-info.outputs.version }}-${{ matrix.tag }}" >> $GITHUB_ENV
- name: "Prepare work directory"
run: |
mkdir /tmp/work
cp ./.github/workflows/docker/Dockerfile.${{ matrix.tag }} /tmp/work/Dockerfile
cd /tmp/work
- name: "Download artifact"
uses: "actions/download-artifact@v3"
with:
name: "${{ matrix.artifact }}"
path: /tmp/work/starkli

- name: "Build Docker image"
run: |
cd /tmp/work
docker build -t $DOCKER_TAG .
- name: "Push Docker image"
run: |
docker push $DOCKER_TAG
release-docker-multiarch:
name: "Build Docker multi-arch image"
runs-on: "ubuntu-latest"
needs:
- "crate-info"
- "release-docker-images"

steps:
- name: "Login to Docker Hub"
uses: "docker/login-action@v2"
with:
username: "${{ secrets.DOCKER_USERNAME }}"
password: "${{ secrets.DOCKER_PASSWORD }}"

- name: "Pull arch-specific images"
run: |
docker pull starknet/starkli:${{ needs.crate-info.outputs.version }}-amd64
docker pull starknet/starkli:${{ needs.crate-info.outputs.version }}-arm64
- name: "Publish multi-arch manifest"
run: |
docker manifest create starknet/starkli:${{ needs.crate-info.outputs.version }} \
starknet/starkli:${{ needs.crate-info.outputs.version }}-amd64 \
starknet/starkli:${{ needs.crate-info.outputs.version }}-arm64
docker manifest create starknet/starkli:latest \
starknet/starkli:${{ needs.crate-info.outputs.version }}-amd64 \
starknet/starkli:${{ needs.crate-info.outputs.version }}-arm64
docker manifest push starknet/starkli:${{ needs.crate-info.outputs.version }}
docker manifest push starknet/starkli:latest
publish-release:
name: "Publish release"
runs-on: "ubuntu-latest"
Expand All @@ -308,6 +392,7 @@ jobs:
- "release-non-apple"
- "release-apple"
- "release-android"
- "release-docker-multiarch"

steps:
- name: "Publish release"
Expand Down

0 comments on commit d6fe7e6

Please sign in to comment.