From aa91ee8d7a01663ab1fb9a5187edb69e5bd008e4 Mon Sep 17 00:00:00 2001 From: Nathan Young Date: Sat, 19 Sep 2026 01:47:28 -0600 Subject: [PATCH] Added docker image files --- .gitea/scripts/update_dockerhub_api | 25 +++++++++++++++ .gitea/workflows/docker_build.yml | 50 +++++++++++++++++++++++++++++ Dockerfile | 20 ++++++++++++ bin/update_dockerhub_api | 25 +++++++++++++++ 4 files changed, 120 insertions(+) create mode 100755 .gitea/scripts/update_dockerhub_api create mode 100644 .gitea/workflows/docker_build.yml create mode 100644 Dockerfile create mode 100755 bin/update_dockerhub_api diff --git a/.gitea/scripts/update_dockerhub_api b/.gitea/scripts/update_dockerhub_api new file mode 100755 index 0000000..d6d6245 --- /dev/null +++ b/.gitea/scripts/update_dockerhub_api @@ -0,0 +1,25 @@ +#!/bin/bash + +DOCKERHUB_USERNAME="${1}" +DOCKERHUB_PASSWORD="${2}" +GITEA_OWNER_REPO="${3}" +GITEA_API_KEY="${4}" +gitea_username=$(echo "${GITEA_OWNER_REPO}" | sed 's/\/.*//') +repo_name=$(echo "${GITEA_OWNER_REPO}" | sed 's/^.*\///') + +NEW_DOCKERHUB_TOKEN=$(curl -s -X POST "https://hub.docker.com/v2/auth/token" \ + -H "Content-Type: application/json" \ + -d "{\"identifier\": \"${DOCKERHUB_USERNAME}\", \"secret\": \"${DOCKERHUB_PASSWORD}\"}" \ + | jq -r .access_token) + +curl -X 'PUT' \ + "https://gitea.happylizard.me/api/v1/repos/${gitea_username}/${repo_name}/actions/secrets/DOCKERHUB_TOKEN" \ + -H 'accept: application/json' \ + -H "Authorization: token ${GITEA_API_KEY}" \ + -H 'Content-Type: application/json' \ + -d "{ + \"data\": \"${NEW_DOCKERHUB_TOKEN}\", + \"description\": \"\" +}" + + diff --git a/.gitea/workflows/docker_build.yml b/.gitea/workflows/docker_build.yml new file mode 100644 index 0000000..0460715 --- /dev/null +++ b/.gitea/workflows/docker_build.yml @@ -0,0 +1,50 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - docker_upload + +jobs: + docker: + runs-on: ubuntu-latest + + steps: + - id: get-repo-name + name: Grab formatted repo name + run: | + repository_name=$(echo ${{ gitea.repository }} | sed 's/^.*\///') + echo "repository-name=$repository_name" >> "$GITEA_OUTPUT" + - name: Print repo name (for testing) + run: | + echo "Repository name: ${{ steps.get-repo-name.outputs.repository-name }}" + + - name: Checkout repository + uses: actions/checkout@v4 + + - run: | + ./bin/update_dockerhub_api \ + ${{ secrets.DOCKERHUB_USERNAME }} \ + ${{ secrets.DOCKERHUB_PASSWORD }} \ + ${{ gitea.repository }} \ + ${{ secrets.API_KEY }} + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + registry: docker.io + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: | + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.get-repo-name.outputs.repository-name }}:latest + docker.io/${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.get-repo-name.outputs.repository-name }}:${{ gitea.sha }} + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f576503 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM python:3-alpine3.15 +WORKDIR /app + +# Install the application dependencies +# COPY . ./ +COPY happy_ripper.py ./ +COPY requirements.txt ./ +COPY templates ./ +COPY tmp ./ + +RUN pip install --no-cache-dir -r requirements.txt +RUN apk add --no-cache ffmpeg + +EXPOSE 5000 + +## Setup an app user so the container doesn't run as the root user +#RUN useradd app +#USER app + +CMD ["python3", "./happy_ripper.py"] diff --git a/bin/update_dockerhub_api b/bin/update_dockerhub_api new file mode 100755 index 0000000..d6d6245 --- /dev/null +++ b/bin/update_dockerhub_api @@ -0,0 +1,25 @@ +#!/bin/bash + +DOCKERHUB_USERNAME="${1}" +DOCKERHUB_PASSWORD="${2}" +GITEA_OWNER_REPO="${3}" +GITEA_API_KEY="${4}" +gitea_username=$(echo "${GITEA_OWNER_REPO}" | sed 's/\/.*//') +repo_name=$(echo "${GITEA_OWNER_REPO}" | sed 's/^.*\///') + +NEW_DOCKERHUB_TOKEN=$(curl -s -X POST "https://hub.docker.com/v2/auth/token" \ + -H "Content-Type: application/json" \ + -d "{\"identifier\": \"${DOCKERHUB_USERNAME}\", \"secret\": \"${DOCKERHUB_PASSWORD}\"}" \ + | jq -r .access_token) + +curl -X 'PUT' \ + "https://gitea.happylizard.me/api/v1/repos/${gitea_username}/${repo_name}/actions/secrets/DOCKERHUB_TOKEN" \ + -H 'accept: application/json' \ + -H "Authorization: token ${GITEA_API_KEY}" \ + -H 'Content-Type: application/json' \ + -d "{ + \"data\": \"${NEW_DOCKERHUB_TOKEN}\", + \"description\": \"\" +}" + +