diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ec95954 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM node:10.11-alpine +LABEL maintainer="Tanguy Herbron " + +ARG CRONICLE_VERSION='0.8.57' + +RUN apk add --no-cache git curl wget perl bash perl-pathtools tar \ + procps tini + +RUN adduser cronicle -D -h /opt/cronicle + +USER cronicle + +WORKDIR /opt/cronicle/ + +RUN mkdir -p data logs plugins +RUN chown cronicle:cronicle data logs plugins + +RUN curl -L "https://github.com/jhuckaby/Cronicle/archive/v${CRONICLE_VERSION}.tar.gz" | tar zxvf - --strip-components 1 && \ + npm install && \ + node bin/build.js dist + +ADD entrypoint.sh /entrypoint.sh + +EXPOSE 3012 + +ENTRYPOINT ["/sbin/tini", "--"] + +CMD ["sh", "/entrypoint.sh"] + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f69837f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3.2" + +services: + cronicle: + build: + context: . + hostname: localhost + ports: + - 3012:3012 + environment: + - CRONICLE_base_app_url=http://localhost:3012 + - CRONICLE_WebServer__http_port=3012 + - CRONICLE_WebServer__https_port=443 + - CRONICLE_web_socket_use_hostnames=1 + - CRONICLE_server_comm_use_hostnames=1 + - CRONICLE_web_direct_connect=0 + - CRONICLE_SETUP=true + volumes: + - ./data:/opt/cronicle/data:rw + - ./logs:/opt/cronicle/logs:rw diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..44b6d24 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +ROOT_DIR=/opt/cronicle +CONF_DIR=$ROOT_DIR/conf +BIN_DIR=$ROOT_DIR/bin +LIB_DIR=$ROOT_DIR/lib +# DATA_DIR needs to be the same as the exposed Docker volume in Dockerfile +DATA_DIR=$ROOT_DIR/data +# PLUGINS_DIR needs to be the same as the exposed Docker volume in Dockerfile +PLUGINS_DIR=$ROOT_DIR/plugins + +# The env variables below are needed for Docker and cannot be overwritten +export CRONICLE_Storage__Filesystem__base_dir=${DATA_DIR} +export NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt +export CRONICLE_echo=1 +export CRONICLE_foreground=1 + +# Only run setup when setup needs to be done +if [ "$CRONICLE_SETUP" = true ] && [ ! -f $DATA_DIR/.setup_done ] +then + $BIN_DIR/control.sh setup + + cp $CONF_DIR/config.json $CONF_DIR/config.json.origin + + if [ -f $DATA_DIR/config.json.import ] + then + # Move in custom configuration + cp $DATA_DIR/config.json.import $CONF_DIR/config.json + fi + + # Create plugins directory + mkdir -p $PLUGINS_DIR + + # Marking setup done + touch $DATA_DIR/.setup_done +fi + +# Run cronicle +/usr/local/bin/node "$LIB_DIR/main.js" +