diff --git a/Dockerfile b/Dockerfile index eac66a1..dea7cf7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,14 @@ -FROM debian:bullseye-slim +FROM alpine:latest ENV CRONICLE_foreground=1 ENV CRONICLE_echo=1 ENV CRONICLE_color=1 ENV EDITOR=vi -ENV MODE=master +ENV MODE=manager -RUN apt update && apt install -y tini curl git +#RUN apt update && apt install -y tini curl git procps -RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - - -RUN apt install nodejs +RUN apk update && apk add bash tini git procps nodejs npm RUN git clone https://github.com/cronicle-edge/cronicle-edge.git /opt/cronicle @@ -24,10 +22,12 @@ COPY run.sh / RUN chmod +x /run.sh +RUN mkdir /config + #RUN ln -sf /dev/stdout /opt/cronicle/logs/Cronicle.log EXPOSE 3012 -ENTRYPOINT ["/usr/bin/tini", "--"] +ENTRYPOINT ["/sbin/tini", "--"] CMD [ "/run.sh" ] \ No newline at end of file diff --git a/README.md b/README.md index ce010c0..b300927 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,21 @@ Dockerised Cronicle, based on the [Cronicle-Edge](https://github.com/cronicle-edge/cronicle-edge) fork. -Can function in both the **master** and **worker** role. +Can function in both the **manager** and **worker** role. ## Running + +`config.json`, located in `/config/config.json`, is automatically generated on the first run of Cronicle in 'manager' mode. This file must be kept identical between the manager and any workers it controls. + +NOTE: You need to define the hostname of the container if using `docker run`. Cronicle expects the hostname to remain the same, so the randomly-generated container hostname can cause problems if it changes. Docker Compose containers inherit their hostname from the `container_name` parameter, but it can also be defined using `hostname: xyz`. + ### Docker CLI ``` docker run -d --name cronicle \ + --hostname cronicle-docker \ -p 3012:3012 \ - -e MODE=master \ + -e MODE=manager \ + -v {path on host}:/config git.mrmeeb.stream/mrmeeb/cronicle:latest ``` @@ -26,16 +33,23 @@ services: restart: unless-stopped ports: - 3012:3012 + volumes: + - {path on host}:/config environment: - - MODE=master + - MODE=manager ``` ## Ports |Port |Purpose | -|-----|--------- | -|3012 |WebUI | +|-----|----------| +|3012 |WebUI and communication between manager and workers| + +## Volumes +|Mount |Purpose | +|-----|-----------| +|/config |Persistent config file and job configurations| ## Environment Variables |Variable|Options|Default|Description| |--------|-------|-------|-------| -|MODE |master, worker|master|Determines what mode Cronicle runs in \ No newline at end of file +|MODE |manager, worker|manager|Determines what mode Cronicle runs in \ No newline at end of file diff --git a/run.sh b/run.sh index 0eab704..8078bed 100644 --- a/run.sh +++ b/run.sh @@ -1,17 +1,41 @@ #!/bin/bash -echo $MODE +mv -n /opt/cronicle/conf/config.json /config/config.json +rm -rf /opt/cronicle/conf/config.json +ln -s /config/config.json /opt/cronicle/conf/config.json -if [ $MODE == "master" ] +if [ $MODE == "manager" ] then - echo "Cronicle is running in 'master' mode" + echo "Cronicle is running in 'manager' mode" + + if [ ! -f /config/data/.setup_done ] + then + echo "Setup needed - running now" + + /opt/cronicle/bin/control.sh setup + touch /opt/cronicle/data/.setup_done + + mv -n /opt/cronicle/data /config/data + rm -rf /opt/cronicle/data + ln -s /config/data /opt/cronicle/data + + exec node /opt/cronicle/lib/main.js --color 1 + + else + + rm -rf /opt/cronicle/data + ln -s /config/data /opt/cronicle/data + + exec node /opt/cronicle/lib/main.js --color 1 + + fi + elif [ $MODE == "worker" ] then echo "Cronicle is running in 'worker' mode" + + exec node /opt/cronicle/lib/main.js --color 1 + else - echo "This is not a recognised mode. Accepted options are 'master' and 'worker'" -fi - -#/opt/cronicle/bin/control.sh setup - -#exec node /opt/cronicle/lib/main.js --color 1 \ No newline at end of file + echo "'$MODE' is not a recognised option for MODE. Accepted options are 'manager' and 'worker'" +fi \ No newline at end of file