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: |
|
run: |
|
||||||
# set the right strip executable
|
# set the right strip executable
|
||||||
STRIP="strip";
|
STRIP="strip";
|
||||||
case ${{ matrix.job.target }} in
|
case ${{ matrix.job.target }} in
|
||||||
arm*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
|
arm*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
|
||||||
aarch64-*-linux-*) STRIP="aarch64-linux-gnu-strip" ;;
|
aarch64-*-linux-*) STRIP="aarch64-linux-gnu-strip" ;;
|
||||||
esac;
|
esac;
|
||||||
cd target/${{ matrix.job.target }}/release
|
cd target/${{ matrix.job.target }}/release
|
||||||
@@ -235,6 +235,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git push origin --follow-tags
|
git push origin --follow-tags
|
||||||
|
|
||||||
|
- name: Fetch updated repository
|
||||||
|
run: |
|
||||||
|
git fetch origin
|
||||||
|
git reset --hard origin/main
|
||||||
|
|
||||||
- name: Create a GitHub Release
|
- name: Create a GitHub Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
env:
|
env:
|
||||||
@@ -282,11 +287,10 @@ jobs:
|
|||||||
name: Publishing Docker image to Docker Hub
|
name: Publishing Docker image to Docker Hub
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Get release artifacts
|
- name: Checkout repository
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
name: artifacts
|
fetch-depth: 1
|
||||||
path: artifacts
|
|
||||||
|
|
||||||
- name: Set version variable
|
- name: Set version variable
|
||||||
run: |
|
run: |
|
||||||
@@ -297,6 +301,12 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "Release version: ${{ env.version }}"
|
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
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
@@ -306,15 +316,11 @@ jobs:
|
|||||||
- name: Push to Docker Hub
|
- name: Push to Docker Hub
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
tags: darkalex17/managarr:latest, darkalex17/managarr:x86_64, darkalex17/managarr:x86_64-${{ env.version }}
|
context: .
|
||||||
push: true
|
file: Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
- name: Push to Docker Hub
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
file: Dockerfile.arm64
|
|
||||||
tags: darkalex17/managarr:arm64, darkalex17/managarr:arm64-${{ env.version }}
|
|
||||||
push: true
|
push: true
|
||||||
|
tags: darkalex17/testing:latest, darkalex17/testing:${{ env.version }}
|
||||||
|
|
||||||
publish-crate:
|
publish-crate:
|
||||||
needs: publish-github-release
|
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
|
WORKDIR /usr/src
|
||||||
|
|
||||||
# Download and compile Rust dependencies in an empty project and cache as a separate Docker layer
|
# 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
|
RUN rm -r src
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
# remove previous deps
|
# 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 \
|
RUN --mount=type=cache,target=/volume/target \
|
||||||
--mount=type=cache,target=/root/.cargo/registry \
|
--mount=type=cache,target=/root/.cargo/registry \
|
||||||
cargo build --release --bin managarr
|
cargo build --release --bin managarr
|
||||||
RUN mv target/x86_64-unknown-linux-musl/release/managarr .
|
RUN mv target/release/managarr .
|
||||||
|
|
||||||
FROM debian:stable-slim
|
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