Skip to content

Commit

Permalink
gerboweb: Add prod container build
Browse files Browse the repository at this point in the history
  • Loading branch information
jaseg committed Jul 5, 2022
1 parent 3ba9322 commit 00de98d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
18 changes: 18 additions & 0 deletions gerboweb/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM docker.io/archlinux:latest
MAINTAINER [email protected]
RUN pacman --noconfirm -Syu
RUN pacman --noconfirm -Sy pugixml opencv pango cairo git python make clang cargo python-pip base-devel gerbv rsync tmux uwsgi uwsgi-plugin-python
RUN cargo install usvg resvg
RUN python3 -m pip install pip==21.3.1
RUN python3 -m pip install flask numpy lxml wasmtime svg_flatten_wasi resvg_wasi flask_wtf
RUN --mount=type=bind,rw,destination=/git \
cd /git/gerbonara && \
python3 -m pip --disable-pip-version-check install . && \
cd /git && \
python3 -m pip --disable-pip-version-check install .
RUN mkdir /gerboweb
ADD ["gerboweb/uwsgi-gerboweb.ini","gerboweb/gerboweb.py","gerboweb/job_processor.py","gerboweb/job_queue.py","/gerboweb/"]
ADD ["gerboweb/static","/gerboweb/"]
ADD ["gerboweb/templates","/gerboweb/"]
ADD gerboweb/gerboweb_prod.cfg /gerboweb/gerboweb.cfg
ENTRYPOINT uwsgi --ini /gerboweb/uwsgi-gerboweb.ini --chmod-socket=660 --socket=/run/uwsgi/socket
1 change: 1 addition & 0 deletions gerboweb/ansible/uwsgi-gerboweb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ plugins = python3
chdir = /var/lib/gerboweb
mount = /=gerboweb:app
env = GERBOWEB_SETTINGS=gerboweb_prod.cfg
mule = job_processor.py

6 changes: 6 additions & 0 deletions gerboweb/gerboweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import uuid
from functools import wraps
from os import path
from pathlib import Path
import os
import sqlite3

Expand All @@ -20,6 +21,11 @@

app = Flask(__name__, static_url_path='/static')
app.config.from_envvar('GERBOWEB_SETTINGS')
if app.config['SECRET_KEY'] is None:
if (p := Path('/run/secrets/gerboweb')).isfile():
app.config['SECRET_KEY'] = p.read_bytes()
else:
app.config['SECRET_KEY'] = os.urandom(32)

class UploadForm(FlaskForm):
upload_file = FileField(validators=[DataRequired()])
Expand Down
1 change: 0 additions & 1 deletion gerboweb/gerboweb.cfg → gerboweb/gerboweb_prod.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
MAX_CONTENT_LENGTH=10000000
SECRET_KEY="FIXME: CHANGE THIS KEY"
UPLOAD_PATH="/var/cache/gerboweb/upload"
JOB_QUEUE_DB="/var/cache/gerboweb/job_queue.sqlite3"
11 changes: 11 additions & 0 deletions gerboweb/uwsgi-gerboweb.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[uwsgi]
master = True
cheap = True
die-on-idle = False
manage-script-name = True
plugins = python3
chdir = /gerboweb
mount = /=gerboweb:app
env = GERBOWEB_SETTINGS=gerboweb.cfg
mule = job_processor.py

0 comments on commit 00de98d

Please sign in to comment.