Add docker configurations for deployment

This commit is contained in:
Tanguy Herbron 2021-05-04 14:44:47 +02:00
parent 89db13a8be
commit 5348320772
3 changed files with 89 additions and 0 deletions

29
Dockerfile Normal file
View File

@ -0,0 +1,29 @@
FROM node:10.11-alpine
LABEL maintainer="Tanguy Herbron <tanguy.herbron@outlook.com>"
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"]

20
docker-compose.yml Normal file
View File

@ -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

40
entrypoint.sh Normal file
View File

@ -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"