diff --git a/Dockerfile b/Dockerfile index e6a7ea0b..e588a372 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,30 @@ -# pull official base image -FROM python:3.6.9 +FROM python:3.6-alpine -# set environment varibles -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 -# set work directory -WORKDIR /opaque +RUN apk add build-base -# Copy the current directory contents into the container at /daemon -COPY . /opaque -# Install requirements -RUN pip install --trusted-host pypi.python.org -r requirements.txt +RUN adduser -D opaque +USER opaque -# set permissions for entrypoint -RUN chmod a+x flask-entrypoint.sh + +WORKDIR /home/opaque + + +COPY app app +COPY migrations migrations +COPY opaque.py config.py ./ +COPY requirements.txt requirements.txt + + +RUN python -m venv venv && \ + venv/bin/pip install -r requirements.txt + + +COPY docker-entrypoint.sh /usr/local/bin/ + + +EXPOSE 5000 + + +ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 00000000..535d86a0 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# If no argument is given, start Opaque +if [ $# -eq 0 ] +then + venv/bin/python opaque.py +else + if [[ $1 == "--create-db" ]] + then + flask db init + flask db upgrade + fi +fi diff --git a/flask-entrypoint.sh b/flask-entrypoint.sh deleted file mode 100644 index ed4b193f..00000000 --- a/flask-entrypoint.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -x - -python opaque.py diff --git a/opaque.py b/opaque.py index 3f8483af..8d4b0101 100644 --- a/opaque.py +++ b/opaque.py @@ -1,7 +1,5 @@ import eventlet eventlet.monkey_patch() -from dotenv import load_dotenv -load_dotenv() from app import create_app, db, socketio from app.models import Corpus, User, Role, Permission, Job from flask_migrate import Migrate diff --git a/requirements.txt b/requirements.txt index 2592d001..19d3e6ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,5 +8,4 @@ Flask-SQLAlchemy Flask-Table Flask-WTF jsonpatch -python-dotenv redis