Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
fresh
Commits
8daefd9acb64
Commit
57c5b7e9
authored
May 22, 2019
by
Philippe Pepiot
Browse files
[docker] use hub.extranet.logilab.fr/cubicweb/cubicweb:3.26-onbuild
parent
c5f6e769051c
Changes
7
Hide whitespace changes
Inline
Side-by-side
.dockerignore
View file @
8daefd9a
**
!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
Dockerfile
View file @
8daefd9a
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"]
Makefile
View file @
8daefd9a
...
...
@@ -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/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
...
...
README.rst
View file @
8daefd9a
...
...
@@ -11,10 +11,10 @@ can edit the code locally and run it in the container.
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 @@ To create the initial database from an existing empty database::
--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
...
...
deploy/deployment.yaml
View file @
8daefd9a
...
...
@@ -7,7 +7,7 @@ data:
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 @@ data:
}
location /data {
alias /etc/cubicweb.d/
fresh
/data;
alias /etc/cubicweb.d/
instance
/data;
expires 30d;
}
}
...
...
@@ -62,12 +62,12 @@ spec:
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 @@ spec:
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 @@ spec:
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
:
...
...
docker/entrypoint.sh
deleted
100644 → 0
View file @
c5f6e769
#!/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
docker/uwsgi.ini
deleted
100644 → 0
View file @
c5f6e769
[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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment