From 194d6cdf5fe24df1b30a26f3f7442f40fff26c21 Mon Sep 17 00:00:00 2001 From: Eric P Date: Sat, 9 Sep 2023 19:50:31 -0500 Subject: [PATCH 1/2] Added GitHub Action to build and deploy Docker images to DockerHub --- .github/workflows/docker-image.yml | 56 ++++++++++++++++++++++++ Dockerfile | 68 ++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 .github/workflows/docker-image.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..48f97d6 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,56 @@ +name: Docker Image CI + +on: + workflow_dispatch: + push: + branches: + - main + tags: + - 'v*' + +env: + REGISTRY: docker.io + IMAGE_NAME: ericpp/helipad + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}},value=${{ inputs.version }} + type=semver,pattern={{major}}.{{minor}},value=${{ inputs.version }} + type=semver,pattern={{major}},value=${{ inputs.version }} + type=raw,value=latest,enable={{is_default_branch}} + flavor: | + latest=false + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ef6bcd9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,68 @@ +### +##: Set up native compile +### +FROM rust:bookworm AS build-native +RUN apt-get update && apt-get install -y ca-certificates openssl sqlite3 +RUN echo $(arch)-unknown-linux-gnu > /tmp/rust-target + +### +##: Set up arm64 cross compile +### +FROM --platform=$BUILDPLATFORM rust:bookworm AS build-cross-arm64 + +ARG CC=aarch64-linux-gnu-gcc +ARG CXX=aarch64-linux-gnu-g++ +ARG PKG_CONFIG_SYSROOT_DIR=/usr/lib/aarch64-linux-gnu/ +ARG CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc + +RUN dpkg --add-architecture arm64 +RUN apt-get update +RUN apt-get install -y g++-aarch64-linux-gnu +RUN apt-get install -y libsqlite3-dev:arm64 libssl-dev:arm64 + +RUN rustup target add aarch64-unknown-linux-gnu +RUN echo aarch64-unknown-linux-gnu > /tmp/rust-target + +### +##: Build targets +### +FROM build-native AS build-arm64-on-arm64 +FROM build-native AS build-amd64-on-amd64 +FROM build-cross-arm64 AS build-arm64-on-amd64 + +##### + +### +##: Build stage +### +FROM build-$TARGETARCH-on-$BUILDARCH as builder + +WORKDIR /opt/helipad + +COPY . /opt/helipad +RUN cargo build --release --target=$(cat /tmp/rust-target) +RUN cp ./target/$(cat /tmp/rust-target)/release/helipad . + +### +##: Bundle stage +### +FROM --platform=$TARGETPLATFORM debian:bookworm-slim AS runner + +RUN apt-get update && \ + apt-get install -y ca-certificates openssl sqlite3 && \ + rm -fr /var/lib/apt/lists/* + +WORKDIR /opt/helipad + +COPY --from=builder /opt/helipad/helipad . +COPY --from=builder /opt/helipad/webroot ./webroot +COPY --from=builder /opt/helipad/helipad.conf . + +RUN useradd -u 1000 helipad +RUN mkdir /data && chown -R 1000:1000 /data + +USER helipad + +EXPOSE 2112/tcp + +ENTRYPOINT ["/opt/helipad/helipad"] From 47b319c6cd30c56ec0bc514474f6581762026738 Mon Sep 17 00:00:00 2001 From: Eric P Date: Thu, 14 Sep 2023 19:56:20 -0500 Subject: [PATCH 2/2] testing --- LICENSE | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LICENSE b/LICENSE index 050fdcd..16b02de 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,5 @@ +testing + MIT License Copyright (c) 2021 Podcastindex.org