Skip to content

Commit

Permalink
add Dockerfile and release workflow for Docker GHCR
Browse files Browse the repository at this point in the history
  • Loading branch information
stackia committed Jan 18, 2025
1 parent 47b8d4f commit bf6308e
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/release-docker.yaml
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
66 changes: 66 additions & 0 deletions Dockerfile
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"]

0 comments on commit bf6308e

Please sign in to comment.