ソースを参照

Merge pull request #109 from scossu/docker

Docker
Stefano Cossu 4 年 前
コミット
d453cc0c73
6 ファイル変更38 行追加29 行削除
  1. 31 13
      Dockerfile
  2. 1 1
      bin/fcrepo
  3. 3 2
      docker-compose.yml
  4. 0 10
      docker/docker_entrypoint
  5. 2 2
      docker/etc/application.yml
  6. 1 1
      lakesuperior/wsgi.py

+ 31 - 13
Dockerfile

@@ -1,15 +1,33 @@
-FROM        python:3.7
-MAINTAINER  Michael B. Klein <michael.klein@northwestern.edu>
-RUN         mkdir -p /usr/local /data
-WORKDIR     /usr/local
-ADD         . lakesuperior
-WORKDIR     /usr/local/lakesuperior
-RUN         git submodule update --init
-RUN         [[ -f lakesuperior/model/base.c ]] || \
-                pip install -r requirements_dev.txt
+FROM        python:3.7-alpine
+LABEL       "maintainer"="Michael B. Klein <michael.klein@northwestern.edu>" \
+            "maintainer"="Stefano Cossu <scossu@getty.edu>"
+
+RUN         apk add --no-cache build-base git
+RUN         pip3 install cython==0.29.6 cymem
+
+RUN         mkdir -p /data
+WORKDIR     /usr/local/lsup/src
+COPY        .git ./.git
+COPY        ext ./ext
+COPY        bin ./bin
+COPY        lakesuperior ./lakesuperior
+COPY        setup.py README.rst ./
+
+RUN         git submodule update --init ext
 RUN         pip install -e .
-RUN         cp ./docker/etc/* ./lakesuperior/etc.defaults/
-CMD         ./docker/docker_entrypoint
+COPY        ./docker/etc ./lakesuperior/etc.defaults
+
+# Clean up build-required packages & dirs.
+RUN         apk del build-base git
+RUN         rm -rf .git
+
+RUN         [ -f /data/ldprs_store/data.mdb ] || \
+                echo yes | lsup-admin bootstrap
+
+VOLUME      /data
+
 EXPOSE      8000
-HEALTHCHECK --interval=30s --timeout=5s \
-  CMD curl -X OPTIONS -f http://localhost:8000/ || exit 1
+
+ENTRYPOINT  ["gunicorn", "-c", "python:lakesuperior.wsgi", \
+            "lakesuperior.server:fcrepo"]
+#ENTRYPOINT  ["./bin/fcrepo"]

+ 1 - 1
bin/fcrepo

@@ -1,3 +1,3 @@
-#!/bin/bash
+#!/bin/sh
 
 gunicorn -c python:lakesuperior.wsgi lakesuperior.server:fcrepo

+ 3 - 2
docker-compose.yml

@@ -1,11 +1,12 @@
-version: '2'
+version: '3'
 
 volumes:
   lakesuperior:
 
 services:
   lakesuperior:
-    image: scossu/lakesuperior:stable
+    build:
+      context: .
     volumes:
       - lakesuperior:/data
     ports:

+ 0 - 10
docker/docker_entrypoint

@@ -1,10 +0,0 @@
-#!/bin/sh
-
-mkdir -p /data/log /data/run /data/bootstrap
-cp ./data/bootstrap/* /data/bootstrap
-pip install -e .
-coilmq &
-if [ ! -d /data/ldpnr_store ] && [ ! -d /data/ldprs_store ]; then
-  echo yes | lsup-admin bootstrap
-fi
-exec fcrepo

+ 2 - 2
docker/etc/application.yml

@@ -10,7 +10,7 @@
 #   One of ``prod``, ``test`` or ``dev``.
 #   ``prod`` is normal running mode. 'test' is used for running test suites.
 #   ``dev`` is similar to normal mode but with reload and debug enabled.
-app_mode: 'dev'
+app_mode: 'prod'
 
 ###
 #   Base data directory.
@@ -23,7 +23,7 @@ app_mode: 'dev'
 #   the individual subdirectories can be mounted on different file systems.
 #
 #   If unset, it will default to <lakesuperior package root>/data.
-data_dir:
+data_dir: /data
 
 ###
 # Configuration for binary path and fixity check generation. The hash is a

+ 1 - 1
lakesuperior/wsgi.py

@@ -89,7 +89,7 @@ group = __def.config.get('group')
 raw_env = 'APP_MODE={}'.format(__app_mode)
 
 preload_app = __def.config.get('preload_app', __def.preload_app)
-daemon = __app_mode == 'prod'
+#daemon = __app_mode == 'prod'
 reload = __app_mode == 'dev' and not preload_app
 
 pidfile = os.path.join(__def.run_dir, 'fcrepo.pid')