Skip to content

Commit

Permalink
run app with gunicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
dnlbauer committed Nov 27, 2022
1 parent baed307 commit 233c14e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# build pdfact
# STEP 1: build pdfact
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y maven git

WORKDIR /
# TODO freeze revision?
RUN git clone https://github.com/ad-freiburg/pdfact.git
WORKDIR pdfact

RUN mvn install -DskipTests

# STEP 2: run service
FROM alpine:latest
WORKDIR /

Expand All @@ -26,12 +29,15 @@ RUN apk add --no-cache python3 \
&& python3 -m ensurepip \
&& pip3 install --upgrade pip setuptools

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install flask app
WORKDIR /app
COPY ./requirements.txt .
RUN pip install -r requirements.txt

COPY app.py .
ENTRYPOINT ["python3"]
CMD ["app.py"]
COPY app.py gunicorn.conf.py ./

ENTRYPOINT ["gunicorn", "--conf", "gunicorn.conf.py", "--bind", "0.0.0.0:80", "app:app"]
8 changes: 8 additions & 0 deletions gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
loglevel = "info"
errorlog = "-" # stderr
accesslog = "-" # stdout
worker_tmp_dir = "/dev/shm"
graceful_timeout = 120
timeout = 120
keepalive = 5
threads = 4
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Flask==2.2.2
Flask==2.2.2
gunicorn==20.1.0

0 comments on commit 233c14e

Please sign in to comment.