Skip to content
Snippets Groups Projects
Commit b9a8c63a authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

Dockerize the Application.

parent 10446740
No related branches found
No related tags found
No related merge requests found
FROM python:3.6-alpine FROM python:3.6-alpine
EXPOSE 5000
ENV FLASK_APP=opaque.py
RUN apk add \ RUN apk add \
build-base \ build-base \
postgresql-dev postgresql-dev
...@@ -8,28 +14,15 @@ RUN apk add \ ...@@ -8,28 +14,15 @@ RUN apk add \
RUN adduser -D opaque RUN adduser -D opaque
USER opaque USER opaque
WORKDIR /home/opaque WORKDIR /home/opaque
COPY app app COPY app app
COPY migrations migrations copy migrations migrations
COPY config.py opaque.py ./ COPY config.py opaque.py requirements.txt ./
COPY requirements.txt requirements.txt
ENV FLASK_APP=opaque.py
RUN python -m venv venv && \ RUN python -m venv venv && \
venv/bin/pip install -r requirements.txt venv/bin/pip install -r requirements.txt
COPY docker-entrypoint.sh /usr/local/bin/ COPY docker-entrypoint.sh /usr/local/bin/
EXPOSE 5000
ENTRYPOINT ["docker-entrypoint.sh"] ENTRYPOINT ["docker-entrypoint.sh"]
version: '3.7' version: '3'
services: services:
web: opaque:
build: . container_name: opaque
container_name: opaque_flask depends_on:
image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque - opaque_database
volumes: - opaque_redis
- .:/opaque
- $HOME/opaque_test:/home/compute/mnt/opaque
env_file: env_file:
- .env - opaque_database_env
- .env_database - opaque_env
image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque:latest
ports: ports:
- 5000:5000 - 5000:5000
depends_on: restart: always
- 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: volumes:
- /home/stephan/Repos/own/opaque/data_dev.sqlite:/daemon/db/data_dev.sqlite - /opaque_storage:/opaque_storage
- $HOME/.docker/config.json:/root/.docker/config.json opaque_daemon:
container_name: opaque_daemon
depends_on: depends_on:
- db - opaque_database
db:
container_name: opaque_db
image: postgres:11.5
env_file: env_file:
- .env_database - opaque_database_env
ports: image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque_daemon:latest
- 5432:5432 restart: always
volumes: volumes:
- postgres_data:/var/lib/postgresql/data - $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 restart: always
volumes:
postgres_data:
...@@ -2,14 +2,12 @@ ...@@ -2,14 +2,12 @@
if [ $# -eq 0 ] if [ $# -eq 0 ]
then then
# If no argument is given, start Opaque
venv/bin/python opaque.py venv/bin/python opaque.py
else else
if [[ $1 == "--create-db" ]] if [[ $1 == "--setup-database" ]]
then then
source venv/bin/activate venv/bin/python -m flask db init
flask db init venv/bin/python -m flask db upgrade
flask db upgrade venv/bin/python -m flask insert-initial-database-entries
flask foo
fi fi
fi fi
...@@ -28,8 +28,8 @@ def test(): ...@@ -28,8 +28,8 @@ def test():
unittest.TextTestRunner(verbosity=2).run(tests) unittest.TextTestRunner(verbosity=2).run(tests)
@app.cli.command() @app.cli.command('insert-initial-database-entries')
def foo(): def insert_initial_database_entries():
Role.insert_roles() Role.insert_roles()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment