Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -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 }}
68 changes: 68 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
testing

MIT License

Copyright (c) 2021 Podcastindex.org
Expand Down