Commit 35843548 authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

Use cubicweb/cubicweb:3.26-onbuild base image

The image contains all we need except we use a modified pyramid.ini
parent ad634fba708c
**
!docker/requirements.txt
!docker/entrypoint.sh
!docker/pyramid.ini.j2
!docker/uwsgi.ini
!setup.py
!MANIFEST.in
!README.rst
!cubicweb_intranet/*.py
!cubicweb_intranet/migration/*.py
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 -e /src
RUN python3 -m pip install --no-cache-dir --disable-pip-version-check -r /src/docker/requirements.txt
# 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=intranet
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"]
......@@ -21,7 +21,10 @@ run: build
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/intranet@$(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/intranet deployment/intranet-scheduler
......
#!/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
[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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment