Skip to content

Commit

Permalink
custom bookwyrm build
Browse files Browse the repository at this point in the history
This bookwyrm build runs periodically, building the latest tag
of Bookwyrm. It also patches settings.py to retain database
connections for a set period of time, instead of creating a new
database connection for each request.
  • Loading branch information
jrasanen committed Mar 24, 2024
0 parents commit bef7eaf
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build and Push to Docker Hub

on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: '0 */2 * * *'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Test checkout
uses: actions/checkout@v4

- name: Fetch the latest Bookwyrm release tag
id: bookwyrm_release
run: |
LATEST_RELEASE=$(curl -s https://api.github.com/repos/bookwyrm-social/bookwyrm/releases/latest | jq -r .tag_name)
echo "Latest release tag is $LATEST_RELEASE"
echo "::set-output name=tag::$LATEST_RELEASE"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check out Bookwyrm repository at the latest tag
uses: actions/checkout@v4
with:
repository: bookwyrm-social/bookwyrm
ref: ${{ steps.bookwyrm_release.outputs.tag }}
path: "bookwyrm"

- name: Copy our Dockerfile into Bookwyrm context
run: cp Dockerfile bookwyrm/Dockerfile

- name: Have database connections open for an hour, instead of opening a new one for each request.
run: |
echo 'CONN_MAX_AGE=3600' >> bookwyrm/bookwyrm/settings.py
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and Push
uses: docker/build-push-action@v5
with:
context: ./bookwyrm
file: ./bookwyrm/Dockerfile
push: true
tags: jrasanen/bookwyrm:${{ steps.bookwyrm_release.outputs.tag }}
platforms: linux/amd64,linux/arm64
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.9

ENV PYTHONUNBUFFERED 1

RUN mkdir /app /app/static /app/images

WORKDIR /app

COPY requirements.txt /app/
RUN pip install -r requirements.txt --no-cache-dir

COPY . /app

CMD ["gunicorn", "bookwyrm.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3"]
Binary file added README.md
Binary file not shown.

0 comments on commit bef7eaf

Please sign in to comment.