Création de l’image Docker de Carto-SI¶
Ce document décrit la recette qui est utilisée pour créer l’image Docker qui est livrée par Carto-SI.
Télécharger les binaires de Carto-SI¶
Les binaires de Carto-SI sont téléchargeables sous la forme d’une archive tar. Les informations pour télécharger l’archive sont disponibles dans le document Télécharger Carto-SI.
Déposer l’archive dans le dossier du Dockerfile
.
Fichier de configuration par défaut¶
Par défaut, le fichier de configuration autorise uniquement la connexion depuis localhost
, ce qui interdit les connections depuis l’extérieur.
Il est donc nécessaire de créer un fichier de configuration ayant listen-localhost-only
à false
. Pour cela, nous allons utiliser un entrypoint
docker.
La ligne password :
est utilisé par le script entrypoint.sh
pour définir le mot de passe depuis la variable d’environnement PASSWORD
.
Le fichier carto-si.properties
:
mailadmin : admin@carto-si.com
password :
anonyme : false
#JWTs be signed using a secret (with the HMAC algorithm)
jwt-secret :
default-tenant : default
log-level : info
# configuration du HTTPS
#keystore-version : TLS
#keystore-type : PKCS12
# 'JKS' generated by keytool(JDK) or generated by PKCS12 OpenSSL
#keystore-file : /data/keynotore.pfx
#the path to the keystore file
#keystore-password : password
#the keystore password
#port-https : 443
port-http : 9327
listen-localhost-only: false
# urlserveur : http://localhost:80/
Le fichier entrypoint.sh
:
#!/bin/sh
CONF_DIR=/carto-si/data/conf
CONF_FILE=$CONF_DIR/carto-si.properties
if [ ! -d $CONF_DIR ] ; then
mkdir -p $CONF_DIR
fi
if [ ! -d $CONF_DIR ] ; then
echo Unable to create $CONF_DIR
exit 1
fi
if [ ! -f $CONF_FILE ] ; then
sed "s//$PASSWORD/" /carto-si/entrypoint/carto-si.properties > $CONF_FILE
fi
if [ ! -f $CONF_FILE ] ; then
echo Unable to copy default configuration
exit 1
fi
exec "$@"
Le Dockerfile¶
Tous les fichiers de l’archive n’étant pas utile, elle est déployée dans un builder pour économiser de la place. Les fichiers nécessaires à l’image sont copiés à la fin du Dockerfile.
Carto-SI a besoin au minimum d’une JRE Java 11. Sur certaines distributions Linux, il est nécessaire de rajouter la bibliothèque Argon2.
Le fichier Dockerfile
:
FROM alpine AS builder
ARG VERSION=0.0.0
ADD carto-distribution-${VERSION}-bin.tar.gz /carto-si
RUN mkdir -p /carto-si/entrypoint
COPY entrypoint.sh /carto-si/entrypoint/entrypoint.sh
COPY carto-si.properties /carto-si/entrypoint/carto-si.properties
RUN chmod a+rx /carto-si/entrypoint && \
chmod a+rx /carto-si/entrypoint/entrypoint.sh && \
chmod a+r /carto-si/entrypoint/carto-si.properties
FROM alpine
RUN apk add openjdk11-jre-headless argon2-dev && \
mkdir -p /carto-si/data && \
adduser --uid 1500 -g "Carto-SI" --disabled-password carto-si && \
chown carto-si /carto-si/data
COPY --from=builder /carto-si/client /carto-si/client
COPY --from=builder /carto-si/core /carto-si/core
COPY --from=builder /carto-si/entrypoint /carto-si/entrypoint
USER carto-si
WORKDIR /carto-si
ENV JAVAOPTS="-Xmx4096m -Xms4096m"
ENTRYPOINT ["/carto-si/entrypoint/entrypoint.sh"]
CMD java $JAVAOPTS -classpath `ls /carto-si/core/* | tr "\n" ':'` synapse.carto.Runner /carto-si/
Construire l’image Docker¶
L’image docker est construite avec la commande suivante :
VERSION=4.3.21
docker build --build-arg VERSION=$VERSION -t registry.gitlab.com/c3772/cartosi/carto-si:$VERSION .