This project helps to build CubicWeb based applications as Docker images. Builds include various versions of cubicweb and python and are using Debian base images.
Images with cubicweb pre-installed:
latest, 3.32, py37-buster-3.32dev, py37-buster-dev (built using latest mercurial changeset)3.31, py37-buster-3.313.30, py37-buster-3.303.29, py37-buster-3.293.28, py37-buster-3.283.27, py37-buster-3.273.26, py37-buster-3.263.25, py27-buster-3.25py35-stretch-3.27py35-stretch-3.26py27-buster-3.26py27-stretch-3.26py27-buster-3.25py27-stretch-3.25Image without cubicweb installed:
py37, py37-busterpy35, py35-stretchpy27, py27-busterpy27-stretchImage for building debian packages:
buildpackage, buster-buildpackagestretch-buildpackageThe image include required packages to build a cubicweb application image suitable for production. It's designed to be used as a parent image for your application Dockerfile.
The image contains:
The entrypoint can also be used to run various command like database
creation with db-create or to run arbitrary commands.
The image has some expectations:
CUBE environment variable.CW_INSTANCE. Although you shouldn't need to modify this.There are multiple ways to use theses images corresponding to different levels of integration.
Here are some hints to make the best choice:
onbuild images are useful when the Dockerfile in versioned in the
source tree, except when your cube require a build toolchain to
install. However they are DEPRECATED.For example, given you're in the source tree of cubicweb-blog:
FROM logilab/cubicweb
USER root
COPY . /src
RUN pip install -e /src
USER cubicweb
RUN docker-cubicweb-helper create-instance
In case of out-of-source tree or not installing from /src directory, you
will also have to set the CUBE environment variable:
FROM logilab/cubicweb
USER root
RUN pip install cubicweb-blog
USER cubicweb
ENV CUBE=blog
RUN docker-cubicweb-helper create-instance
Warning
A lot of magic happen with onbuild images. They are DEPRECATED.
All images have a onbuild version by adding the suffix -onbuild. The
single tag onbuild is an alias for py37-buster-3.28-onbuild.
These images use the ONBUILD intruction to copy current code to the build context and install your cube in develop mode and create an instance of your cube.
For example, given you're in the source tree of cubicweb-blog, a Dockerfile would be as simple as:
FROM logilab/cubicweb:onbuild
You can even build an image without actually writing any Dockerfile:
echo "FROM logilab/cubicweb:onbuild" | docker build -f - -t cubicweb-blog .
In case you don't want a cubicweb version pre-installed and let your own dependencies control what version to install:
FROM logilab/cubicweb:py37-onbuild
Environment variables control settings from all-in-one.conf, most
important are:
CW_BASE_URL (default http://localhost:8080) should be set to the
final url the instance will be accessed with. Including the scheme,
for example: https://myapp.demo.logilab.orgCW_DB_DRIVER (default postgres), CW_DB_NAME, CW_DB_USER and
CW_DB_PASSWORD control database settingsCW_LOGIN and CW_PASSWORD control the admin login and password,
default to admin:adminThis can be used to validate your image actually works:
docker run --rm -it -e CW_DB_NAME=db.sqlite myimage sh -c "cubicweb-ctl db-create -a instance && uwsgi --ini /etc/uwsgi/uwsgi.ini"
Then go to http://localhost:8080 to access your instance.
To create the initial database you will have to run db-create first:
For example:
# Create the database on local postgresql cluster in a database named "myapp"
docker run --rm -it -e CW_DB_NAME=myapp CW_DB_USER=me -v /var/run/postgresql:/var/run/postgresql myimage db-create
# Create the database on remote postgresql server in a database named "myapp"
docker run --rm -it -e CW_DB_NAME=myapp CW_DB_USER=me CW_DB_PASSWORD=secret CW_DB_HOST=dbserver myimage db-create
# Create the database in a local /tmp/db.sqlite file
docker run --rm -it -e CW_DB_NAME=/tmp/db.sqlite -v /tmp/db.sqlite:/tmp/db.sqlite myimage db-create
To start uwsgi server on local port 8080:
# run foreground
docker run --rm -it -p 8080:8080 myapp
# run in background
docker run -d --restart=always --name myapp myapp
To run cubicweb looping tasks, you will also have to start the
scheduler:
# run foreground
docker run --rm -it myapp cubicweb-ctl scheduler instance
# run in background
docker run -d --restart=always --name myapp-scheduler myapp cubicweb-ctl scheduler instance
In case of source tree builds, add a .dockerignore to your project to
avoid copying useless files inside the docker image. For example:
.*
*.egg-info
**/__pycache__
Dockerfile
Jenkinsfile
Makefile
tox.ini
test
debian
Always pull the base image before running the build. Base images are rebuild in case of debian security update or new pypi releases.
These images can be used to build debian package(s) and publish them to a repo located in /repo suitable for use within a multi-stage build.
Example, given all dependencies are available on "deb http://apt.logilab.fr buster cubicweb-3.28" repository and given you're working in the source tree of cubicweb-blog:
FROM logilab/cubicweb:buildpackage as buildpackage
COPY . /src
RUN buildpackage -d /src
FROM logilab/cubicweb:3.28
COPY --from=buildpackage /repo /repo
RUN apt-get update && apt-get -y --no-install-recommends install cubicweb-blog
ENV CUBE=blog
USER cubicweb
RUN docker-cubicweb-helper create-instance
If you need to build more packages, or build specific revisions, the
buildpackage script can also build from an archive:
FROM logilab/cubicweb:buster-buildpackage
RUN buildpackage -u https://hg.logilab.org/master/cubes/comment/archive/tip.tar.gz
COPY . /src
RUN buildpackage -d /src
[...]
Content type
Image
Digest
Size
127.6 MB
Last updated
about 5 years ago
docker pull logilab/cubicweb