forked from oskar456/rtp2httpd
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Dockerfile and release workflow for Docker GHCR
- Loading branch information
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Docker Release | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Build stage | ||
FROM --platform=$BUILDPLATFORM debian:bullseye-slim AS builder | ||
|
||
ARG TARGETPLATFORM | ||
ARG BUILDPLATFORM | ||
|
||
# Install build dependencies | ||
RUN set -ex; \ | ||
apt-get update; \ | ||
apt-get install -y \ | ||
autoconf \ | ||
automake \ | ||
pkg-config; \ | ||
case "$TARGETPLATFORM" in \ | ||
"$BUILDPLATFORM") apt-get install -y build-essential ;; \ | ||
"linux/arm64") \ | ||
dpkg --add-architecture arm64 && \ | ||
apt-get install -y \ | ||
crossbuild-essential-arm64 \ | ||
gcc-aarch64-linux-gnu ;; \ | ||
"linux/arm/v7") \ | ||
dpkg --add-architecture armhf && \ | ||
apt-get install -y \ | ||
crossbuild-essential-armhf \ | ||
gcc-arm-linux-gnueabihf ;; \ | ||
"linux/amd64") \ | ||
dpkg --add-architecture amd64 && \ | ||
apt-get install -y \ | ||
crossbuild-essential-amd64 \ | ||
gcc-x86-64-linux-gnu ;; \ | ||
*) echo "Unsupported platform combination: $BUILDPLATFORM -> $TARGETPLATFORM" && exit 1 ;; \ | ||
esac && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy source code | ||
WORKDIR /workdir | ||
COPY . . | ||
|
||
RUN case "$TARGETPLATFORM" in \ | ||
"$BUILDPLATFORM") ARCH_FLAGS="" ;; \ | ||
"linux/amd64") ARCH_FLAGS="--host=x86_64-linux-gnu" ;; \ | ||
"linux/arm64") ARCH_FLAGS="--host=aarch64-linux-gnu" ;; \ | ||
"linux/arm/v7") ARCH_FLAGS="--host=arm-linux-gnueabihf" ;; \ | ||
esac && \ | ||
echo "Building with ARCH_FLAGS=$ARCH_FLAGS" && \ | ||
autoreconf -fi && \ | ||
./configure ${ARCH_FLAGS} && \ | ||
make | ||
|
||
# Runtime stage | ||
FROM debian:bullseye-slim | ||
|
||
# Install runtime dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
libgcc1 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Copy the built binary and config | ||
COPY --from=builder /workdir/src/rtp2httpd /usr/local/bin/ | ||
COPY --from=builder /workdir/rtp2httpd.conf /usr/local/etc/ | ||
|
||
# Expose the default port | ||
EXPOSE 8080 | ||
|
||
# Run the application | ||
ENTRYPOINT ["/usr/local/bin/rtp2httpd"] |