From e55dba66e4171410a73cbe890a3de80c75f7f041 Mon Sep 17 00:00:00 2001 From: marwin Date: Mon, 16 Mar 2026 19:24:06 +0100 Subject: [PATCH] Add Dockerfile and Forgejo Actions workflow for Docker builds --- .forgejo/workflows/docker.yml | 38 +++++++++++++++++++++++++++++++++++ Dockerfile | 18 +++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .forgejo/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.forgejo/workflows/docker.yml b/.forgejo/workflows/docker.yml new file mode 100644 index 0000000..88573c6 --- /dev/null +++ b/.forgejo/workflows/docker.yml @@ -0,0 +1,38 @@ +name: Build and push Docker image + +on: + push: + branches: + - master + - testing + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set image tag + id: tag + run: | + if [ "${{ github.ref_name }}" = "master" ]; then + echo "tag=latest" >> $GITHUB_OUTPUT + else + echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT + fi + + - name: Log in to Forgejo registry + uses: docker/login-action@v3 + with: + registry: fg.creamfresh.xyz + username: ${{ github.actor }} + password: ${{ secrets.FORGEJO_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: fg.creamfresh.xyz/mrwnslz/diora-web:${{ steps.tag.outputs.tag }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0f3ca40 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.12-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt gunicorn + +COPY . . + +RUN python manage.py collectstatic --noinput + +EXPOSE 8000 + +CMD ["gunicorn", "diora.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "2"]