Dockerize the Application.

This commit is contained in:
Patrick Jentsch 2019-09-06 11:38:35 +02:00
parent 1044674074
commit b9a8c63aee
4 changed files with 46 additions and 59 deletions

View File

@ -1,6 +1,12 @@
FROM python:3.6-alpine
EXPOSE 5000
ENV FLASK_APP=opaque.py
RUN apk add \
build-base \
postgresql-dev
@ -8,28 +14,15 @@ RUN apk add \
RUN adduser -D opaque
USER opaque
WORKDIR /home/opaque
COPY app app
COPY migrations migrations
COPY config.py opaque.py ./
COPY requirements.txt requirements.txt
ENV FLASK_APP=opaque.py
copy migrations migrations
COPY config.py opaque.py 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"]

View File

@ -1,42 +1,38 @@
version: '3.7'
version: '3'
services:
web:
build: .
container_name: opaque_flask
image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque
volumes:
- .:/opaque
- $HOME/opaque_test:/home/compute/mnt/opaque
opaque:
container_name: opaque
depends_on:
- opaque_database
- opaque_redis
env_file:
- .env
- .env_database
- opaque_database_env
- opaque_env
image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque:latest
ports:
- 5000:5000
depends_on:
- db
links:
- db
command: bash flask-entrypoint.sh
daemon:
container_name: opaque_daemon
image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/daemon_opaque
network_mode: "host"
volumes:
- /home/stephan/Repos/own/opaque/data_dev.sqlite:/daemon/db/data_dev.sqlite
- $HOME/.docker/config.json:/root/.docker/config.json
depends_on:
- db
db:
container_name: opaque_db
image: postgres:11.5
env_file:
- .env_database
ports:
- 5432:5432
volumes:
- postgres_data:/var/lib/postgresql/data
restart: always
volumes:
postgres_data:
volumes:
- /opaque_storage:/opaque_storage
opaque_daemon:
container_name: opaque_daemon
depends_on:
- opaque_database
env_file:
- opaque_database_env
image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque_daemon:latest
restart: always
volumes:
- $HOME/.docker/config.json:/home/opaque_daemon/.docker/config.json
opaque_database:
container_name: opaque_database
env_file: opaque_database_env
image: postgres:alpine
restart: always
volumes:
- /opaque_database:/var/lib/postgresql/data
opaque_redis:
container_name: opaque_redis
image: redis:alpine
restart: always

View File

@ -2,14 +2,12 @@
if [ $# -eq 0 ]
then
# If no argument is given, start Opaque
venv/bin/python opaque.py
else
if [[ $1 == "--create-db" ]]
if [[ $1 == "--setup-database" ]]
then
source venv/bin/activate
flask db init
flask db upgrade
flask foo
venv/bin/python -m flask db init
venv/bin/python -m flask db upgrade
venv/bin/python -m flask insert-initial-database-entries
fi
fi

View File

@ -28,8 +28,8 @@ def test():
unittest.TextTestRunner(verbosity=2).run(tests)
@app.cli.command()
def foo():
@app.cli.command('insert-initial-database-entries')
def insert_initial_database_entries():
Role.insert_roles()