From 5418303b082412b73c69fc88fc35d512418d2628 Mon Sep 17 00:00:00 2001 From: dbrennand <52419383+dbrennand@users.noreply.github.com> Date: Tue, 22 Jun 2021 00:03:27 +0100 Subject: [PATCH] ARMV7 Docker Image (#234) * feat: Push dockerfile. Progress on trying to get armv7 image. * feat: Add Dockerfile. Using rust:slim as builder image. * refactor: Changes to build for armv7. * feat: Add .cargo config. Taken from: https://medium.com/swlh/compiling-rust-for-raspberry-pi-arm-922b55dbb050 * refactor: Add environment variable for linker. Instead of .cargo config file. * feat: Working cross compile version. For Armv7. * refactor: Clean up dockerfile. * refactor: Rename to armv7. Rename Dockerfile.armv7rust to Dockerfile.armv7. * feat: Add workflow to build ARMv7 docker image. * docs: Add armv7 deployment instructions. --- .github/workflows/docker-armv7.yml | 39 +++++++++++++++++++++++++++ Dockerfile.armv7 | 43 ++++++++++++++++++++++++++++++ README.md | 4 ++- 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-armv7.yml create mode 100644 Dockerfile.armv7 diff --git a/.github/workflows/docker-armv7.yml b/.github/workflows/docker-armv7.yml new file mode 100644 index 0000000..3229418 --- /dev/null +++ b/.github/workflows/docker-armv7.yml @@ -0,0 +1,39 @@ +name: Docker ARM V7 Build + +on: + push: + paths-ignore: + - "**.md" + branches: + - master + +jobs: + build-docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up QEMU + id: qemu + uses: docker/setup-qemu-action@v1 + with: + platforms: all + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + version: latest + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push + id: build_push + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile.armv7 + platforms: linux/arm/v7 + push: true + tags: spikecodes/libreddit:armv7 diff --git a/Dockerfile.armv7 b/Dockerfile.armv7 new file mode 100644 index 0000000..d28141c --- /dev/null +++ b/Dockerfile.armv7 @@ -0,0 +1,43 @@ +#################################################################################################### +## Builder +#################################################################################################### +FROM --platform=$BUILDPLATFORM rust:slim AS builder + +ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-gcc +ENV CC_armv7_unknown_linux_musleabihf=arm-linux-gnueabihf-gcc + +RUN apt-get update && apt-get -y install gcc-arm-linux-gnueabihf \ + binutils-arm-linux-gnueabihf \ + musl-tools + +RUN rustup target add armv7-unknown-linux-musleabihf + +WORKDIR /libreddit + +COPY . . + +RUN cargo build --target armv7-unknown-linux-musleabihf --release + +#################################################################################################### +## Final image +#################################################################################################### +FROM alpine:latest + +# Import ca-certificates from builder +COPY --from=builder /usr/share/ca-certificates /usr/share/ca-certificates +COPY --from=builder /etc/ssl/certs /etc/ssl/certs + +# Copy our build +COPY --from=builder /libreddit/target/armv7-unknown-linux-musleabihf/release/libreddit /usr/local/bin/libreddit + +# Use an unprivileged user. +RUN adduser --home /nonexistent --no-create-home --disabled-password libreddit +USER libreddit + +# Tell Docker to expose port 8080 +EXPOSE 8080 + +# Run a healthcheck every minute to make sure Libreddit is functional +HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1 + +CMD ["libreddit"] diff --git a/README.md b/README.md index c843549..9c419ae 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Libreddit -> An alternative private front-end to Reddit +> An alternative private front-end to Reddit ![screenshot](https://i.ibb.co/QYbqTQt/libreddit-rust.png) @@ -165,6 +165,8 @@ docker run -d --name libreddit -p 80:8080 spikecodes/libreddit To deploy on `arm64` platforms, simply replace `spikecodes/libreddit` in the commands above with `spikecodes/libreddit:arm`. +To deploy on `armv7` platforms, simply replace `spikecodes/libreddit` in the commands above with `spikecodes/libreddit:armv7`. + ## 3) AUR For ArchLinux users, Libreddit is available from the AUR as [`libreddit-git`](https://aur.archlinux.org/packages/libreddit-git).