Skip to content

Commit

Permalink
Merge pull request #3 from Kirens/feature/generate-image
Browse files Browse the repository at this point in the history
Generate Docker image
  • Loading branch information
Kirens authored Oct 28, 2021
2 parents a327596 + 1c87760 commit 47d9441
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 34 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish Docker Image

on:
release:
types: [ published ]

env:
# GitHub repository is basically "$org/$repo"
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v2

# User triggering the action is authenticated to the container registry
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Basically sets the image tag from the release
- name: Extract metadata for Docker
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
14 changes: 14 additions & 0 deletions .github/workflows/try-build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Build Docker image.

on:
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ RUN apt-get clean \
&& apt-get -y update

WORKDIR /src
ADD requirements.txt /src
COPY requirements.txt /src
RUN pip install -r requirements.txt
ADD src /src/
COPY src /src/

ENV SECRET_KEY verysecretXd
ENV PORT 4001
EXPOSE $PORT

CMD uwsgi --enable-threads --http-socket :$PORT --module tv:app
7 changes: 0 additions & 7 deletions Makefile

This file was deleted.

11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ A day starts at 5:00 and ends at 5:00 the next day. This means that an end date
The default priority is 0. If a PR has its priority set to 1, it will be the only PR shown until its end date (useful for pubs etc.).

## Running in Docker
```
git clone https://github.com/mightynerd/tvmannen
make build
make up-prod
```
***Important***: Change ```SECRET_KEY``` in ```src/config.py``` to something more secret.
The provided sample compose file should work out of the box provided a
`SECRET_KEY` env-variable. Aditional variables can be found in `src/config.py`.

See docker-compose.yml/docker-compose.prod.yml for ports, which you probably want to change. A default admin account will be created on first start (if no existing database is present). Visit ```/login``` and login with "admin" and "pass".
At first launc the database is populated with a user _admin_ with the password
_pass_. It is suggested you change this immediately.
7 changes: 0 additions & 7 deletions docker-compose.prod.yml

This file was deleted.

14 changes: 12 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
version: '3'
version: '3.7'

services:
web:
build: .
restart: always
ports:
- "4001:4001"
- "4001:4001"
environment:
- SECRET_KEY
- DATABASE_URI=sqlite:////db/data
volumes:
- db:/db
- uploads:/src/static/pr

volumes:
db:
uploads:
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Flask==1.1.1
uWSGI==2.0.17.1
Flask-SQLAlchemy==2.4.1
flask_wtf==0.14.2
Flask-SQLAlchemy==2.5
flask_wtf==0.14.3
WTForms==2.2.1
flask_login==0.4.1
21 changes: 14 additions & 7 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@


class Config(object):
SECRET_KEY = "verysecretXd"
MAX_CONTENT_LENGTH = 5 * 1024 * 1024
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(curdir, 'db.db')
SECRET_KEY = os.environ["SECRET_KEY"]
MAX_CONTENT_LENGTH = int(os.getenv("MAX_CONTENT_LENGTH", 5 * 1024 * 1024))
SQLALCHEMY_DATABASE_URI = os.getenv(
"DATABASE_URI",
"sqlite:///" + os.path.join(curdir, "db.db"),
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
UPLOAD_FOLDER = os.path.join(curdir, "static", "pr")
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'mp4'}
PR_TIME = 30 # Time for each PR in seconds
PR_FETCH_TIME = 120 # How often the PR list is fetched
UPLOAD_FOLDER = os.getenv("UPLOAD_FOLDER", os.path.join(curdir, "static", "pr"))
ALLOWED_EXTENSIONS = set(
os.getenv("ALLOWED_EXTENSIONS", "png,jpg,jpeg,mp4").split(",")
)
# Time for each PR in seconds
PR_TIME = int(os.getenv("PR_TIME", 30))
# How often the PR list is fetched
PR_FETCH_TIME = int(os.getenv("PR_FETCH_TIME", 120))

0 comments on commit 47d9441

Please sign in to comment.