[docker] use hub.extranet.logilab.fr/cubicweb/cubicweb:3.26-onbuild
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Wed, 22 May 2019 16:56:30 +0200
changeset 108 8daefd9acb64
parent 107 c5f6e769051c
child 109 923b1d1e2d12
[docker] use hub.extranet.logilab.fr/cubicweb/cubicweb:3.26-onbuild
.dockerignore
Dockerfile
Makefile
README.rst
deploy/deployment.yaml
docker/entrypoint.sh
docker/uwsgi.ini
--- a/.dockerignore	Thu May 16 18:15:33 2019 +0200
+++ b/.dockerignore	Wed May 22 16:56:30 2019 +0200
@@ -1,12 +1,10 @@
-**
-!docker/requirements.txt
-!docker/entrypoint.sh
-!docker/pyramid.ini.j2
-!docker/uwsgi.ini
-!MANIFEST.in
-!README.rst
-!setup.py
-!cubicweb_fresh/*.py
-!cubicweb_fresh/migration/*.py
-!cubicweb_fresh/views/*.py
-!cubicweb_fresh/data/*
+.*
+*.egg-info
+**/__pycache__
+Dockerfile
+Jenkinsfile
+Makefile
+tox.ini
+test
+debian
+deploy
--- a/Dockerfile	Thu May 16 18:15:33 2019 +0200
+++ b/Dockerfile	Wed May 22 16:56:30 2019 +0200
@@ -1,49 +1,6 @@
-FROM debian:buster-slim
-ENV LANG C.UTF-8
-RUN mkdir -p /usr/share/man/man1 && mkdir -p /usr/share/man/man7
-RUN apt-get update && apt-get -y --no-install-recommends install \
-    gettext \
-    uwsgi \
-    uwsgi-plugin-python3 \
-    graphviz \
-    postgresql-client \
-    python3-pip \
-    python3-setuptools \
-    python3-crypto \
-    python3-psycopg2 \
-    python3-jinja2 \
-    pwgen \
-    && rm -rf /var/lib/apt/lists/*
-COPY . /src/
-RUN python3 -m pip install --no-cache-dir --disable-pip-version-check -r /src/docker/requirements.txt
-RUN python3 -m pip install --no-cache-dir --disable-pip-version-check -e /src
-# ensure rql is installed with gecode extension
-RUN python3 -c 'import rql.rql_solve'
-RUN useradd cubicweb --uid 1000 -m -s /bin/bash
-RUN install -d -o cubicweb -g cubicweb /etc/cubicweb.d
-COPY docker/uwsgi.ini /etc/uwsgi/uwsgi.ini
-COPY docker/pyramid.ini.j2 /
-COPY docker/entrypoint.sh /entrypoint.sh
-RUN chmod +x /entrypoint.sh
+FROM hub.extranet.logilab.fr/cubicweb/cubicweb:3.26-onbuild
+USER root
+RUN pip install -r /src/docker/requirements.txt
+RUN cp /src/docker/pyramid.ini.j2 /pyramid.ini.j2
 USER cubicweb
-WORKDIR /home/cubicweb
-ENV CW_DOCKER_CUBE=fresh
-ENV CW_INSTANCE=$CW_DOCKER_CUBE
-ENV CW_CUBES_PATH=/usr/local/share/cubicweb/cubes
-ENV CW_INSTANCES_DIR=/etc/cubicweb.d
-ENV CW_INSTANCES_DATA_DIR=/etc/cubicweb.d
-ENV CW_LOG_FILE=/dev/stdout
-ENV CW_LOG_THRESHOLD=WARNING
-ENV CW_DB_HOST=
-ENV CW_DB_USER=cubicweb
-ENV CW_DB_PASSWORD=
-ENV CW_DB_NAME=$CW_INSTANCE
-ENV CW_DB_DRIVER=postgres
-ENV CW_LOGIN=admin
-ENV CW_PASSWORD=admin
 ENV WITH_TRUSTEDAUTH=false
-ENV CW_BASE_URL=http://localhost:8080
-EXPOSE 8080/tcp
-RUN cubicweb-ctl create $CW_DOCKER_CUBE $CW_INSTANCE --automatic --no-db-create
-ENTRYPOINT ["/entrypoint.sh"]
-CMD ["start"]
--- a/Makefile	Thu May 16 18:15:33 2019 +0200
+++ b/Makefile	Wed May 22 16:56:30 2019 +0200
@@ -21,7 +21,10 @@
 dev: build
 	docker run --rm -it $(DOCKER_ARGS) -v `pwd`:/src $(IMAGE) bash
 
-deploy: push
+pull-base:
+	grep '^FROM ' Dockerfile | awk '{ print $$2 }' | xargs docker pull
+
+deploy: pull-base push
 	sed "s@hub.extranet.logilab.fr/logilab/fresh@$(IMAGE)@" deploy/deployment.yaml | kubectl -n $(NAMESPACE) apply -f -
 	@echo "wait at max 3 minutes for deployment to be UP"
 	kubectl -n $(NAMESPACE) wait --for=condition=available --timeout=180s deployment/fresh deployment/fresh-scheduler
--- a/README.rst	Thu May 16 18:15:33 2019 +0200
+++ b/README.rst	Wed May 22 16:56:30 2019 +0200
@@ -11,10 +11,10 @@
 
 Some useful commands::
 
-* ``cubicweb-ctl db-create -a fresh`` will create and initialize the
+* ``cubicweb-ctl db-create -a instance`` will create and initialize the
   database
 
-* ``cubicweb-ctl pyramid -D -l info fresh`` will start the instance on
+* ``cubicweb-ctl pyramid -D -l info instance`` will start the instance on
   http://localhost:8080
 
 Deploying on kubernetes
@@ -28,7 +28,7 @@
       --env CW_DB_PASSWORD=pass \
       --env CW_DB_NAME=fresh \
       --image=hub.extranet.logilab.fr/logilab/fresh --command -- \
-      cubicweb-ctl db-create --automatic --create-db=n fresh
+      cubicweb-ctl db-create --automatic --create-db=n instance
    kubectl delete deployment fresh-dbcreate
 
 
--- a/deploy/deployment.yaml	Thu May 16 18:15:33 2019 +0200
+++ b/deploy/deployment.yaml	Wed May 22 16:56:30 2019 +0200
@@ -7,7 +7,7 @@
   default.conf: |
     server {
       listen 8000 default_server;
-      root /etc/cubicweb.d/fresh/data;
+      root /etc/cubicweb.d/instance/data;
       rewrite ^/fresh/(.*) /$1 last;
 
       location / {
@@ -23,7 +23,7 @@
       }
 
       location /data {
-        alias /etc/cubicweb.d/fresh/data;
+        alias /etc/cubicweb.d/instance/data;
         expires 30d;
       }
     }
@@ -62,12 +62,12 @@
                 name: fresh-env
           volumeMounts:
             - name: static
-              mountPath: /etc/cubicweb.d/fresh/data
+              mountPath: /etc/cubicweb.d/instance/data
             - name: cwclientlibrc
               mountPath: /secret
           command: [
             "/bin/sh", "-c",
-            "install -m 400 /secret/cwclientlibrc /etc/cubicweb.d/fresh/cwclientlibrc && exec /entrypoint.sh start"
+            "install -m 400 /secret/cwclientlibrc /etc/cubicweb.d/instance/cwclientlibrc && exec /entrypoint.sh start"
           ]
           resources:
             requests:
@@ -83,7 +83,7 @@
               mountPath: /etc/nginx/conf.d/default.conf
               subPath: default.conf
             - name: static
-              mountPath: /etc/cubicweb.d/fresh/data
+              mountPath: /etc/cubicweb.d/instance/data
           resources:
             requests:
               cpu: 100m
@@ -134,7 +134,7 @@
               mountPath: /secret
           command: [
             "/bin/sh", "-c",
-            "install -m 400 /secret/cwclientlibrc /etc/cubicweb.d/fresh/cwclientlibrc && exec cubicweb-ctl sheduler fresh"
+            "install -m 400 /secret/cwclientlibrc /etc/cubicweb.d/instance/cwclientlibrc && exec cubicweb-ctl sheduler instance"
           ]
           resources:
             requests:
--- a/docker/entrypoint.sh	Thu May 16 18:15:33 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-#!/bin/sh
-set -e
-PINI=$CW_INSTANCES_DIR/$CW_INSTANCE/pyramid.ini
-if ! test -e $PINI; then
-    test -z "$PYRAMID_SESSION_SECRET" && export PYRAMID_SESSION_SECRET=$(pwgen -s 20)
-    test -z "$PYRAMID_AUTHTKT_SESSION_SECRET" && export PYRAMID_AUTHTKT_SESSION_SECRET=$(pwgen -s 20)
-    test -z "$PYRAMID_AUTHTKT_PERSISTENT_SECRET" && export PYRAMID_AUTHTKT_PERSISTENT_SECRET=$(pwgen -s 20)
-    python3 > $PINI << EOF
-import os
-import jinja2
-print(jinja2.Template(open('/pyramid.ini.j2').read()).render(os.environ))
-EOF
-fi
-check_upgrade() {
-    echo "check the instance is properly bootstraped and up to date"
-    echo "print('OK')" > /tmp/chk.py
-    isok=$(cubicweb-ctl shell $CW_INSTANCE /tmp/chk.py || true)
-    if [ "x$isok" != xOK ]; then
-      echo $isok
-      echo "upgrading instance"
-      cubicweb-ctl upgrade --nostartstop --backup-db=no --force --verbosity=0 $CW_INSTANCE
-    fi
-    cubicweb-ctl gen-static-datadir $CW_INSTANCE
-    cubicweb-ctl i18ninstance $CW_INSTANCE
-}
-case "$1" in
-    start)
-        check_upgrade
-        exec uwsgi --ini /etc/uwsgi/uwsgi.ini
-        ;;
-    db-create)
-        exec cubicweb-ctl db-create --automatic $CW_INSTANCE
-        ;;
-    -h|--help|help)
-        cat << EOF
-Docker image for cubicweb-$CW_DOCKER_CUBE
-
-Usage:
-
-start                   upgrade and start instance
-db-create               initialize database
-
-
-Environment variables:
-
-CW_BASE_URL                             site url (default http://localhost:8080)
-CW_LOG_THRESHOLD                        log level (default WARNING)
-CW_DB_HOST                              database host
-CW_DB_USER                              database user (default cubicweb)
-CW_DB_PASSWORD                          database password
-CW_DB_NAME                              database name (default $CW_INSTANCE)
-CW_DB_DRIVER                            database driver (default postgres)
-WITH_TRUSTEDAUTH                        Disable cubicweb login page (default false)
-CW_SENTRY_DSN                           Sentry DSN
-REDIS_SESSIONS_SECRET
-REDIS_SESSIONS_URL
-PYRAMID_SESSION_SECRET
-PYRAMID_AUTHTKT_SESSION_SECRET
-PYRAMID_AUTHTKT_PERSISTENT_SECRET
-EOF
-        exit 64
-        ;;
-    *)
-        exec $*
-        ;;
-esac
--- a/docker/uwsgi.ini	Thu May 16 18:15:33 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-[uwsgi]
-master = true
-http = 0.0.0.0:8080
-module = cubicweb.pyramid:wsgi_application()
-processes = 2
-threads = 8
-plugins = http,python3
-auto-procname = true
-lazy-apps = true
-log-master = true
-disable-logging = true
-http-timeout = 180