-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
0 parents
commit bef7eaf
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.