Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker suport #80

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:alpine

RUN apk --no-cache add jq

WORKDIR /opt/Cronicle

COPY . /opt/Cronicle/
RUN npm install
RUN node bin/build.js dist

CMD ["/opt/Cronicle/bin/control.sh", "setup_and_start"]

EXPOSE 3012
VOLUME ["/opt/Cronicle/logs", "/opt/Cronicle/data"]
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

IMAGE=cronicle

run: build
docker run --rm -it \
-p 3012:3012 \
$(IMAGE)

build:
docker build -t $(IMAGE) .
28 changes: 28 additions & 0 deletions bin/control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,34 @@ do
node $HOMEDIR/bin/storage-cli.js setup
exit
;;
setup_and_start)
# Only run setup when setup needs to be done
if [ ! -f $HOMEDIR/data/.setup_done ]; then
$HOMEDIR/bin/control.sh setup

mv $HOMEDIR/conf/config.json $HOMEDIR/conf/config.json.origin

if [ -f $HOMEDIR/data/config.json.import ]; then
# Move in custom configuration
cp $HOMEDIR/data/config.json.import $HOMEDIR/conf/config.json
else
# Use default configuration with changes through ENV variables
_WEBSERVER_HTTP_PORT=${WEBSERVER_HTTP_PORT:-3012}

cat $HOMEDIR/conf/config.json.origin | \
jq ".web_socket_use_hostnames = ${WEB_SOCKET_USE_HOSTNAMES:-1}" | \
jq ".server_comm_use_hostnames = ${SERVER_COMM_USE_HOSTNAMES:-1}" | \
jq ".WebServer.http_port = ${_WEBSERVER_HTTP_PORT}" | \
jq ".WebServer.https_port = ${WEBSERVER_HTTPS_PORT:-443}" | \
jq ".base_app_url = \"${BASE_APP_URL:-http://${HOSTNAME}:${WEBSERVER_HTTP_PORT}}\"" \
> $HOMEDIR/conf/config.json
fi

# Marking setup done
touch $HOMEDIR/data/.setup_done
fi
exec $HOMEDIR/bin/debug.sh start
;;
maint)
node $HOMEDIR/bin/storage-cli.js maint $2
exit
Expand Down