From 6db99cfba5c6d7b928f5033a5ff903a0a53a122a Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Fri, 29 Nov 2019 15:08:16 +0100 Subject: [PATCH] Change base image --- Dockerfile | 39 +++++++++++++++++++++------------------ docker-compose.yml | 38 ++++++++------------------------------ docker-entrypoint.sh | 6 +++--- 3 files changed, 32 insertions(+), 51 deletions(-) diff --git a/Dockerfile b/Dockerfile index 01208183..59511c03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,35 @@ -FROM python:3.6-alpine - - -EXPOSE 5000 +FROM python:3.6-slim-stretch ENV FLASK_APP=opaque.py -RUN apk add \ - bash \ - build-base \ - git \ - postgresql-dev +RUN apt-get update \ + && apt-get install --no-install-recommends --yes \ + build-essential \ + libpq-dev \ + wait-for-it \ + && rm -rf /var/lib/apt/lists/* -RUN adduser -D opaque +RUN groupadd --gid 1000 --system opaque \ + && useradd --create-home --gid opaque --no-log-init --system --uid 1000 opaque USER opaque WORKDIR /home/opaque -COPY app app -COPY migrations migrations -COPY config.py opaque.py requirements.txt ./ -RUN python -m venv venv && \ - venv/bin/pip install -r requirements.txt +COPY ["app", "app"] +COPY ["migrations", "migrations"] +COPY ["tests", "tests"] +COPY ["config.py", "opaque.py", "requirements.txt", "./"] +RUN python -m venv venv \ + && venv/bin/pip install --requirement requirements.txt \ + && mkdir logs -# add wait for it -RUN git clone https://github.com/vishnubob/wait-for-it.git -COPY docker-entrypoint.sh /usr/local/bin/ +EXPOSE 5000 +VOLUME ["/home/opaque/logs", "/home/opaque/migrations"] + + +COPY ["docker-entrypoint.sh", "/usr/local/bin/"] ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index 35a95b66..55887900 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,10 +5,6 @@ services: depends_on: - db - redis - deploy: - placement: - constraints: - - node.role == manager env_file: - db.env - web.env @@ -16,52 +12,34 @@ services: ports: - 5000:5000 volumes: - - storage:/mnt/opaque + - /mnt/opaque:/mnt/opaque - ./app:/home/opaque/app - - ./config.py:/home/opaque/config.py - - ./docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh - ./logs:/home/opaque/logs - ./migrations:/home/opaque/migrations + - ./tests:/home/opaque/tests + - ./config.py:/home/opaque/config.py + - ./docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh - ./opaque.py:/home/opaque/opaque.py + - ./requirements.txt:/home/opaque/requirements.txt daemon: depends_on: - db - deploy: - placement: - constraints: - - node.role == manager env_file: - db.env - web.env image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque_daemon:latest volumes: - - storage:/mnt/opaque + - /mnt/opaque:/mnt/opaque - ./logs:/home/opaque_daemon/logs + - ../opaque_daemon/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh - ../opaque_daemon/opaque_daemon.py:/home/opaque_daemon/opaque_daemon.py - ../opaque_daemon/merge_corpus_files.py:/home/opaque_daemon/merge_corpus_files.py - - ../opaque_daemon/config.ini:/home/opaque_daemon/config.ini - - ../opaque_daemon/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh + - ../opaque_daemon/requirements.txt:/home/opaque_daemon/requirements.txt - $HOME/.docker/config.json:/home/opaque_daemon/.docker/config.json db: - deploy: - placement: - constraints: - - node.role == manager env_file: db.env image: postgres:11-alpine volumes: - /srv/opaque/database:/var/lib/postgresql/data redis: - deploy: - placement: - constraints: - - node.role == manager image: redis:alpine - -volumes: - storage: - driver: local - driver_opts: - device: "//127.0.0.1/opaque_storage" - o: "gid=1000,password=opaque,uid=1000,username=opaque" - type: cifs diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 85c9486d..3abf7198 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,9 +1,9 @@ -#!/bin/sh +#!/bin/bash echo "Waiting for db..." -wait-for-it/wait-for-it.sh db:5432 --strict --timeout=0 +wait-for-it db:5432 --strict --timeout=0 echo "Waiting for redis..." -wait-for-it/wait-for-it.sh redis:6379 --strict --timeout=0 +wait-for-it redis:6379 --strict --timeout=0 if [ $# -eq 0 ] then