ci: Attempting multi-platform builds for docker [skip ci]
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
name: Test Docker Multi-Platform Builds
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish-docker-image:
|
||||
name: Publishing Docker image to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set version variable
|
||||
run: |
|
||||
version="$(cat artifacts/release-version)"
|
||||
echo "version=$version" >> $GITHUB_ENV
|
||||
|
||||
- name: Validate release environment variables
|
||||
run: |
|
||||
echo "Release version: ${{ env.version }}"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Push to Docker Hub
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: darkalex17/testing:latest, darkalex17/testing:${{ env.version }}
|
||||
@@ -124,8 +124,8 @@ jobs:
|
||||
run: |
|
||||
# set the right strip executable
|
||||
STRIP="strip";
|
||||
case ${{ matrix.job.target }} in
|
||||
arm*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
|
||||
case ${{ matrix.job.target }} in
|
||||
arm*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
|
||||
aarch64-*-linux-*) STRIP="aarch64-linux-gnu-strip" ;;
|
||||
esac;
|
||||
cd target/${{ matrix.job.target }}/release
|
||||
@@ -235,6 +235,11 @@ jobs:
|
||||
run: |
|
||||
git push origin --follow-tags
|
||||
|
||||
- name: Fetch updated repository
|
||||
run: |
|
||||
git fetch origin
|
||||
git reset --hard origin/main
|
||||
|
||||
- name: Create a GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
env:
|
||||
@@ -282,11 +287,10 @@ jobs:
|
||||
name: Publishing Docker image to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get release artifacts
|
||||
uses: actions/download-artifact@v3
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
name: artifacts
|
||||
path: artifacts
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Set version variable
|
||||
run: |
|
||||
@@ -297,6 +301,12 @@ jobs:
|
||||
run: |
|
||||
echo "Release version: ${{ env.version }}"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
@@ -306,15 +316,11 @@ jobs:
|
||||
- name: Push to Docker Hub
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
tags: darkalex17/managarr:latest, darkalex17/managarr:x86_64, darkalex17/managarr:x86_64-${{ env.version }}
|
||||
push: true
|
||||
|
||||
- name: Push to Docker Hub
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
file: Dockerfile.arm64
|
||||
tags: darkalex17/managarr:arm64, darkalex17/managarr:arm64-${{ env.version }}
|
||||
context: .
|
||||
file: Dockerfile
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: darkalex17/testing:latest, darkalex17/testing:${{ env.version }}
|
||||
|
||||
publish-crate:
|
||||
needs: publish-github-release
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
FROM messense/rust-musl-cross:x86_64-musl AS builder
|
||||
FROM rust:1.82 AS builder
|
||||
WORKDIR /usr/src
|
||||
|
||||
# Download and compile Rust dependencies in an empty project and cache as a separate Docker layer
|
||||
@@ -11,12 +11,12 @@ RUN cargo build --release
|
||||
RUN rm -r src
|
||||
COPY src ./src
|
||||
# remove previous deps
|
||||
RUN rm ./target/x86_64-unknown-linux-musl/release/deps/managarr*
|
||||
RUN rm ./target/release/deps/managarr*
|
||||
|
||||
RUN --mount=type=cache,target=/volume/target \
|
||||
--mount=type=cache,target=/root/.cargo/registry \
|
||||
cargo build --release --bin managarr
|
||||
RUN mv target/x86_64-unknown-linux-musl/release/managarr .
|
||||
RUN mv target/release/managarr .
|
||||
|
||||
FROM debian:stable-slim
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
FROM messense/rust-musl-cross:armv7-musleabihf AS builder
|
||||
WORKDIR /usr/src
|
||||
|
||||
# Download and compile Rust dependencies in an empty project and cache as a separate Docker layer
|
||||
RUN USER=root cargo new --bin managarr-temp
|
||||
RUN apt update && apt install -y libssl-dev pkg-config
|
||||
|
||||
WORKDIR /usr/src/managarr-temp
|
||||
COPY Cargo.* .
|
||||
RUN cargo build --release
|
||||
# remove src from empty project
|
||||
RUN rm -r src
|
||||
COPY src ./src
|
||||
# remove previous deps
|
||||
RUN rm ./target/armv7-unknown-linux-musleabihf/release/deps/managarr*
|
||||
|
||||
RUN --mount=type=cache,target=/volume/target \
|
||||
--mount=type=cache,target=/root/.cargo/registry \
|
||||
cargo build --release --bin managarr
|
||||
RUN mv target/armv7-unknown-linux-musleabihf/release/managarr .
|
||||
|
||||
FROM debian:stable-slim
|
||||
|
||||
# Copy the compiled binary from the builder container
|
||||
COPY --from=builder --chown=nonroot:nonroot /usr/src/managarr-temp/managarr /usr/local/bin
|
||||
|
||||
ENTRYPOINT [ "/usr/local/bin/managarr" ]
|
||||
Reference in New Issue
Block a user