Skip to content

Commit

Permalink
Docker packages setup (#106)
Browse files Browse the repository at this point in the history
* add explicit package building permissions to the action

* try with no cache

* allow environment override in dockerfile

* make note in readme

* stub running with docker section

* add some extra instructions

* more instructions

* use version tag in addition to latest

* fix syntax

* inverted tags
  • Loading branch information
facundoolano authored Jul 15, 2024
1 parent 59be017 commit 4299f8f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
tags:
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
Expand All @@ -15,6 +15,9 @@ jobs:

runs-on: ubuntu-latest

permissions:
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -29,4 +32,6 @@ jobs:
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ WORKDIR /app
# Install python dependencies
COPY requirements.txt ./

RUN pip install -r requirements.txt
RUN pip install -r requirements.txt --no-cache-dir

# Install node dependencies
# Copy both package.json and package-lock.json
Expand All @@ -25,4 +25,7 @@ COPY . .

EXPOSE 9988

CMD [ "gunicorn", "-b0.0.0.0:9988", "--env", "FLASK_ENV=development"]
# run in dev by default, override with docker run -e FLASK_ENV=production
ENV FLASK_ENV=development

CMD ["sh", "-c", "gunicorn -b 0.0.0.0:9988 --env FLASK_ENV=${FLASK_ENV}"]
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ For background about the development of this project, see [this blog post](https
- [Custom feeds](#custom-feeds)
- [Keyboard shortcuts](#keyboard-shortcuts)
- [User management](#user-management)
- [Running with Docker](#running-with-docker)
- [Non-local setup](#non-local-setup)


## Installation
feedi requires Python >= 3.9. If you don't have it installed already consider using [pyenv](https://github.com/pyenv/pyenv#installation) or [asdf](https://asdf-vm.com/guide/getting-started.html).

Expand All @@ -58,7 +58,7 @@ Then, to run the app:

The application will be available at `http://localhost:9988/`.

Alternatively, you can build and run the app in a docker container with `make docker`. Read below for [non-local setup instructions](#non-local-setup).
Alternatively, see the instructions for [running with Docker](#running-with-docker) or in a [non-local setup](#non-local-setup).

## Basic usage
### Adding sources
Expand Down Expand Up @@ -234,5 +234,31 @@ with `make user-del [email protected]`. Note that this will also remove feed

Note that there's no open user registration functionality exposed to the front end, but it should be straightforward to add it if you need it. Check the [auth module](https://github.com/facundoolano/feedi/blob/HEAD/feedi/auth.py) and the [flask-login documentation](https://flask-login.readthedocs.io/en/latest/) for details.

### Running with Docker

Get the image from github packages:

docker pull ghcr.io/facundoolano/feedi:latest

Create a volume for persisting the db data:

docker volume create feedidb

Load the default feeds into the default admin user:

docker run -v feedidb:/app/instance ghcr.io/facundoolano/feedi flask --app feedi/app.py feed load feeds.csv [email protected]
docker run -v feedidb:/app/instance ghcr.io/facundoolano/feedi flask --app feedi/app.py feed sync

Run in development mode:

docker run -p 9988:9988 -v feedidb:/app/instance ghcr.io/facundoolano/feedi

To run in production mode, a config file with at least a secret key is expected:

echo "SECRET_KEY = '$(python -c 'import secrets; print(secrets.token_hex())')'" >> production.py
docker run -p 9988:9988 -e FLASK_ENV=production -v feedidb:/app/instance -v $(pwd)/production.py:/app/feedi/config/production.py ghcr.io/facundoolano/feedi

To enable authentication, add `DEFAULT_AUTH_USER=None` to that production config file.

### Non-local setup
You can refer to the [Flask documentation](https://flask.palletsprojects.com/en/2.1.x/deploying/) for a instructions on how to deploy feedi to a non-local environment. The [setup script](./setup_server.sh) included in the repository shows an example setup for a Debian server. You can run it remotely with ssh like `make prod-install SSH=user@server`.

0 comments on commit 4299f8f

Please sign in to comment.