From a93051bae207da247661fff7e74fbcf443603cae Mon Sep 17 00:00:00 2001 From: mustard Date: Sun, 31 Aug 2025 11:18:09 +0200 Subject: [PATCH] feat: updated Dockerfile and began adding CI/CD for build and deploy --- .forgejo/workflows/build_and_deploy.yaml | 58 ++++++++++++++++++++++++ Dockerfile | 58 ++++++++++++++---------- 2 files changed, 92 insertions(+), 24 deletions(-) create mode 100644 .forgejo/workflows/build_and_deploy.yaml diff --git a/.forgejo/workflows/build_and_deploy.yaml b/.forgejo/workflows/build_and_deploy.yaml new file mode 100644 index 0000000..0cc204c --- /dev/null +++ b/.forgejo/workflows/build_and_deploy.yaml @@ -0,0 +1,58 @@ +name: Docker + +on: + schedule: + # Build the image daily + - cron: '30 21 * * *' + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + REGISTRY: forgejoever.homelab0ne.xyz + IMAGE_NAME: joeverfin + TAG: latest + +jobs: + build: + runs-on: ubuntu-24.04 + permissions: + contents: read + packages: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ forgejo.actor }} + password: ${{ secrets.FORGEJO_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + ${{ env.TAG }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v6 + with: + context: . + push: ${{ forgejo.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 8a77d24..524a3c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,40 +1,23 @@ -FROM alpine:latest +FROM alpine:latest AS build # Install dependencies RUN apk --no-cache add -u -f \ - wget \ curl \ - unzip \ git \ - debhelper \ - gnupg \ - devscripts \ - build-essential \ - mmv \ - lsb-release \ - zip \ - libssl*.* \ - liblttng-ust*\ - libssl-dev \ - libfontconfig*-dev \ - libcurl*openssl-dev \ - libfreetype-dev \ - dotnet8-sdk \ - nodejs \ - npm \ + dotnet9-sdk \ + nodejs \ + npm \ ffmpeg # Fetch jellyfin and jellyfin-web - WORKDIR /home/root RUN git clone https://github.com/jellyfin/jellyfin.git RUN mv jellyfin jellyfin-server RUN git clone https://github.com/jellyfin/jellyfin-web.git # Patch jellyfin-server - RUN sed -i '/^\s*NetworkChange\.Network/d' jellyfin-server/src/Jellyfin.Networking/Manager/NetworkManager.cs -RUN dotnet publish jellyfin-server/Jellyfin.Server --configuration Release --self-contained --runtime linux-amd64 --output /home/root/dist/ -p:DebugSymbols=false -p:DebugType=none -p:UseAppHost=true +RUN dotnet publish jellyfin-server/Jellyfin.Server --configuration Release --self-contained --runtime linux-musl-x64 --output /home/root/dist/jellyfin -p:DebugSymbols=false -p:DebugType=none -p:UseAppHost=true # Build jellyfin-web WORKDIR /home/root/jellyfin-web @@ -42,9 +25,36 @@ RUN npm ci --no-audit --unsafe-perm RUN npm run build:production WORKDIR /home/root -RUN mv /home/root/jellyfin-web/dist /home/root/dist/jellyfin/jellyfin-web +RUN mv /home/root/dist/jellyfin /jellyfin +RUN mv /home/root/jellyfin-web/dist /jellyfin/jellyfin-web +# Add minimal dependencies +FROM alpine:latest AS runtime -ENTRYPOINT ["/home/root/dist/jellyfin/jellyfin"] +RUN apk --no-cache add -u -f \ + ffmpeg \ + icu-libs \ + icu-data-full \ + libstdc++ \ + libstdc++6 +# Add hardened_malloc +COPY --from=ghcr.io/polarix-containers/hardened_malloc:latest /install /usr/local/lib/ +ENV LD_PRELOAD="/usr/local/lib/libhardened_malloc.so" +# Default environment variables for the Jellyfin invocation +ENV DEBIAN_FRONTEND="noninteractive" \ + LC_ALL="en_US.UTF-8" \ + LANG="en_US.UTF-8" \ + LANGUAGE="en_US:en" \ + JELLYFIN_DATA_DIR="/config" \ + JELLYFIN_CACHE_DIR="/cache" \ + JELLYFIN_CONFIG_DIR="/config/config" \ + JELLYFIN_LOG_DIR="/config/log" \ + JELLYFIN_WEB_DIR="/jellyfin/jellyfin-web" \ + JELLYFIN_FFMPEG="/usr/bin/ffmpeg" +# JELLYFIN_FFMPEG="/usr/lib/jellyfin-ffmpeg/ffmpeg" +COPY --from=build /jellyfin /jellyfin +COPY --from=build /jellyfin/jellyfin-web /jellyfin/jellyfin-web + +ENTRYPOINT ["/jellyfin/jellyfin"]