Nuxeo provides a set of Docker images that can be separated into two categories:
The builder images allow to build a final Docker image using a multi-stage build.
The final images are ready to use.
These images are pushed to our public Docker regsitry. To pull an image, run:
docker pull docker.packages.nuxeo.com/IMAGE_NAME:TAGFor instance, to pull the latest 11.1-SNAPSHOT version of the nuxeo/slim image, run:
docker pull docker.packages.nuxeo.com/nuxeo/slim:11.1-SNAPSHOTThese Docker images don't aim to replace the Nuxeo Docker official image. They implement a different approach, described here, to try having immutable images configured at build time instead of runtime.
The versioning of these images follows the Nuxeo platform versioning. In the Dockerfile samples below, VERSION can be replaced for instance by 11.1-SNAPSHOT.
It provides:
- A Nuxeo server distribution with appropriate permissions in the
/distribdirectory. - An
install-packages.shscript to install Nuxeo packages.
It is based on an OpenJDK image as it requires Java for the package installation.
It must be used within a multi-stage build.
For instance, you can use the following Dockerfile sample to build an image based on a BASE_IMAGE, containing a Nuxeo server distribution:
- In the
NUXEO_HOMEdirectory. - With some Nuxeo packages installed, whose ZIP files must be located in the
local/packagesdirectory. - Owned by the UID user and GID group.
FROM nuxeo/builder:VERSION as builder
COPY local/packages /packages
RUN install-packages.sh /packages
FROM BASE_IMAGE
COPY --from=builder --chown=UID:GID /distrib NUXEO_HOMEThis image can be used as the BASE_IMAGE in the Dockerfile samples seen above.
Based on CentOS 7, it includes:
- OpenJDK.
- A
nuxeouser with the900fixed UID. - The directories required to have the Nuxeo configuration, data and logs outside of the server directory, with appropriate permissions.
- An entrypoint script to configure the server.
- The default recommended volumes.
- The environment variables required by the server, typically
NUXEO_HOMEandNUXEO_CONF. - The exposed port
8080.
It doesn't contain the Nuxeo server distribution itself. To build an image containing a Nuxeo server distribution with some packages installed, you must use a multi-stage build with the nuxeo/builder image and the nuxeo/base image, as in the following Dockerfile sample:
FROM nuxeo/builder:VERSION as builder
COPY local/packages /packages
RUN install-packages.sh /packages
FROM nuxeo/base:VERSION
RUN yum -y install ...
COPY --from=builder --chown=900:0 /distrib $NUXEO_HOME
USER 900It includes a bare Nuxeo server distribution without any package installed. It doesn't include any converter.
It is a typical example of an image built using multi-stage with the nuxeo/builder and nuxeo/base images. These images are passed as build args in the Dockerfile.
It includes a bare Nuxeo server distribution with a set of Nuxeo packages pre-installed. These packages are described by the Maven project's POM. It includes basic Open Source converters.
This image is also built using multi-stage with the nuxeo/builder and nuxeo/base images. These images are passed as build args in the Dockerfile.
It requires to install Docker.
There are several ways to build the images, depending on the context:
- For a local build, use Maven.
- For a pipeline running in Jenkins X, use Skaffold.
- In any case, you can use Docker.
To build all the images locally, run:
mvn -nsu installTo build a single image, for instance the nuxeo/builder one, run:
mvn -nsu -f builder/pom.xml installWe use Skaffold to build the images as part of the nuxeo pipeline in our Jenkins X CI/CD platform.
This requires to:
It also requires the following environment variables:
DOCKER_REGISTRY: the Docker registry to push the images to.VERSION: the image tag, for instance11.1-SNAPSHOT.
Because we are using the Kaniko builder and there is no support (yet) for ordering dependant builds, we are relying on several skaffold.yaml files and performing a sequential build, see the skaffoldBuildAll method in the Jenkinsfile.
First, to build the nuxeo/builder and nuxeo/base images, run:
skaffold buildTo build the nuxeo/slim image, run:
skaffold build -f slim/skaffold.yamlTo build the nuxeo/nuxeo image, run:
skaffold build -f nuxeo/skaffold.yamlTo build the nuxeo/builder image, you first need to fetch the Nuxeo distribution and make it available for the Docker build with Maven:
mvn -nsu -f builder/pom.xml process-resourcesThen run:
docker build -t nuxeo/builder:11.1-SNAPSHOT -f builder/Dockerfile builderTo build the nuxeo/base image, run:
docker build -t nuxeo/base:11.1-SNAPSHOT -f base/Dockerfile baseTo build the nuxeo/slim image, run:
docker build -t nuxeo/slim:11.1-SNAPSHOT -f slim/Dockerfile --build-arg BUILDER_IMAGE=nuxeo/builder:11.1-SNAPSHOT --build-arg BASE_IMAGE=nuxeo/base:11.1-SNAPSHOT slimTo build the nuxeo/nuxeo image, you first need to fetch the Nuxeo packages to install and make them available for the Docker build with Maven:
mvn -nsu -f nuxeo/pom.xml process-resourcesThen run:
docker build -t nuxeo/nuxeo:11.1-SNAPSHOT -f nuxeo/Dockerfile --build-arg BUILDER_IMAGE=nuxeo/builder:11.1-SNAPSHOT --build-arg BASE_IMAGE=nuxeo/base:11.1-SNAPSHOT nuxeoFor instance, to run a container from the nuxeo/slim image built locally, run:
docker run -it -p 8080:8080 nuxeo/slim:11.1-SNAPSHOTTo pull the nuxeo/slim image from our public Docker regsitry and run a container from it, run:
docker run -it -p 8080:8080 docker.packages.nuxeo.com/nuxeo/slim:11.1-SNAPSHOTTo inspect the different layers included in an image, you can run for instance:
docker history nuxeo/slim:11.1-SNAPSHOTThe dive tool is also very good for exploring an image, its layer contents and discovering ways to shrink the image size:
dive nuxeo/slim:11.1-SNAPSHOTThough we try to have immutable images configured at build time, in some cases it makes sense to configure a container at runtime. This typically applies to the address and credentials of each back-end store (database, Elasticsearch, S3, etc.) that are specific to a given deployment: development, staging, production, etc.
To add some configuration properties when running a container from a final image, you can mount property files as volumes into the /etc/nuxeo/conf.d directory of the container. Each property file will be appended to nuxeo.conf ordered by filename during startup.
For instance, to append the following postgresql.conf file to nuxeo.conf:
nuxeo.db.name=nuxeo
nuxeo.db.user=nuxeo
nuxeo.db.password=nuxeo
nuxeo.db.host=localhost
nuxeo.db.port=5432you can run:
docker run -it -p 8080:8080 -v /path/to/postgresql.conf:/etc/nuxeo/conf.d/postgresql.conf nuxeo/slim:11.1-SNAPSHOTCurrently, there are two environment variables that are taken into account by a final image: JAVA_OPTS and NUXEO_CLID.
Later on, with NXP-28191, we should be able to configure any Nuxeo property as an environment variable passed to the container.
If provided when running a container, the value of JAVA_OPTS is appended to the JAVA_OPTS property defined in nuxeo.conf at startup.
For instance, to make the Nuxeo Launcher display the JVM settings in the console, run:
docker run -it -p 8080:8080 -e JAVA_OPTS=-XshowSettings:vm nuxeo/slim:11.1-SNAPSHOTIf provided when running a container, the value of NUXEO_CLID is copied to /var/lib/nuxeo/instance.clid at startup.
For instance, running:
docker run -it -p 8080:8080 -e NUXEO_CLID=<NUXEO_CLID> nuxeo/slim:11.1-SNAPSHOTallows to run a container with a registered Nuxeo instance.