Skip to content

Instantly share code, notes, and snippets.

@gorbiz
Created October 24, 2017 16:52
Show Gist options
  • Save gorbiz/8b9130238c35a350b7f1e40584e33aef to your computer and use it in GitHub Desktop.
Save gorbiz/8b9130238c35a350b7f1e40584e33aef to your computer and use it in GitHub Desktop.
CILAMP docker example
# example usage:
# docker build -t lamp .
# docker run -e LAMPID=mylampID -e TEST_CMD='date +%S | grep 1' -e TEST_INTERVAL=60 lamp
FROM alpine
RUN set -ex; \
apk update; \
apk add bash; \
apk add curl
CMD while :; do ( \
eval $TEST_CMD &> /dev/null \
&& (echo TRUE && curl -s -X POST -F "color=${TRUE_COLOR:-#00ff00}" https://api.cilamp.se/v1/$LAMPID/ > /dev/null) \
|| (echo FALSE && curl -s -X POST -F "color=${FALSE_COLOR:-#ff0000}" https://api.cilamp.se/v1/$LAMPID/ > /dev/null) \
); \
sleep $TEST_INTERVAL; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment