mirror of
https://github.com/willfarrell/docker-crontab.git
synced 2025-04-03 21:45:12 +02:00
Using RQ to change toml and yaml to JSON, removing all python stuff
This commit is contained in:
parent
b9bbeacae1
commit
18e9954d74
14
Dockerfile
14
Dockerfile
@ -1,7 +1,19 @@
|
|||||||
|
FROM alpine:3.12 as rq-build
|
||||||
|
|
||||||
|
ENV RQ_VERSION=1.0.2
|
||||||
|
WORKDIR /root/
|
||||||
|
|
||||||
|
RUN apk --update add upx \
|
||||||
|
&& wget https://github.com/dflemstr/rq/releases/download/v${RQ_VERSION}/rq-v${RQ_VERSION}-x86_64-unknown-linux-musl.tar.gz \
|
||||||
|
&& tar -xvf rq-v1.0.2-x86_64-unknown-linux-musl.tar.gz \
|
||||||
|
&& upx --brute rq
|
||||||
|
|
||||||
FROM library/docker:stable
|
FROM library/docker:stable
|
||||||
|
|
||||||
|
COPY --from=rq-build /root/rq /usr/local/bin
|
||||||
|
|
||||||
ENV HOME_DIR=/opt/crontab
|
ENV HOME_DIR=/opt/crontab
|
||||||
RUN apk add --no-cache --virtual .run-deps gettext bash py3-toml py3-yaml python3 jq tini \
|
RUN apk add --no-cache --virtual .run-deps gettext jq bash tini \
|
||||||
&& mkdir -p ${HOME_DIR}/jobs ${HOME_DIR}/projects \
|
&& mkdir -p ${HOME_DIR}/jobs ${HOME_DIR}/projects \
|
||||||
&& adduser -S docker -D
|
&& adduser -S docker -D
|
||||||
|
|
||||||
|
40
config.yml
40
config.yml
@ -0,0 +1,40 @@
|
|||||||
|
- command: echo hello
|
||||||
|
comment: cron with triggered commands
|
||||||
|
container: myapp
|
||||||
|
project: crontab
|
||||||
|
schedule: '* * * * *'
|
||||||
|
trigger:
|
||||||
|
- command: echo world
|
||||||
|
container: crontab_myapp_1
|
||||||
|
- command: echo new
|
||||||
|
comment: map a volume
|
||||||
|
dockerargs: -d -v /tmp:/tmp
|
||||||
|
image: alpine:3.5
|
||||||
|
schedule: '* * * * *'
|
||||||
|
- command: sh -c 'echo hourly ${FOO}'
|
||||||
|
comment: use an ENV from inside a container
|
||||||
|
dockerargs: -d -e FOO=BAR
|
||||||
|
image: alpine:3.5
|
||||||
|
schedule: '@hourly'
|
||||||
|
- command: echo 2 minute
|
||||||
|
comment: trigger every 2 min
|
||||||
|
image: alpine:3.5
|
||||||
|
schedule: '@every 2m'
|
||||||
|
trigger:
|
||||||
|
- command: echo world
|
||||||
|
container: crontab_myapp_1
|
||||||
|
- command: /usr/sbin/logrotate /etc/logrotate.conf
|
||||||
|
schedule: '*/5 * * * *'
|
||||||
|
- command: sh -c 'dehydrated --cron --out /etc/ssl --domain ${LE_DOMAIN} --challenge
|
||||||
|
dns-01 --hook dehydrated-dns'
|
||||||
|
comment: Regenerate Certificate then reload nginx
|
||||||
|
dockerargs: --env-file /opt/crontab/env/letsencrypt.env -v webapp_nginx_tls_cert:/etc/ssl
|
||||||
|
-v webapp_nginx_acme_challenge:/var/www/.well-known/acme-challenge
|
||||||
|
image: willfarrell/letsencrypt
|
||||||
|
onstart: true
|
||||||
|
schedule: 43 6,18 * * *
|
||||||
|
trigger:
|
||||||
|
- command: sh -c '/etc/scripts/make_hpkp ${NGINX_DOMAIN} && /usr/sbin/nginx -t &&
|
||||||
|
/usr/sbin/nginx -s reload'
|
||||||
|
container: nginx
|
||||||
|
project: conduit
|
@ -12,4 +12,4 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
||||||
# - "/usr/bin/docker:/usr/bin/docker:ro"
|
# - "/usr/bin/docker:/usr/bin/docker:ro"
|
||||||
- "/Users/willfarrell/Development/docker/docker-crontab/config.json:/opt/crontab/config.json:rw"
|
- "${PWD}/config.json:/opt/crontab/config.json:rw"
|
||||||
|
@ -17,11 +17,11 @@ fi
|
|||||||
|
|
||||||
get_config() {
|
get_config() {
|
||||||
if [ -f "${HOME_DIR}/config.toml" ]; then
|
if [ -f "${HOME_DIR}/config.toml" ]; then
|
||||||
python3 -c "with open('${HOME_DIR}/config.toml') as ct, open('${HOME_DIR}/config.json', 'w') as cj: import toml; import json; json.dump(list(toml.load(ct).values()), cj)"
|
rq -t <<< $(cat ${HOME_DIR}/config.toml) | jq 'map(.)' > ${HOME_DIR}/config.json
|
||||||
elif [ -f "${HOME_DIR}/config.yml" ]; then
|
elif [ -f "${HOME_DIR}/config.yml" ]; then
|
||||||
python3 -c "with open('${HOME_DIR}/config.yml') as cy, open('${HOME_DIR}/config.json', 'w') as cj: import yaml; import json; json.dump(list(yaml.safe_load(cy).values()), cj)"
|
rq -y <<< $(cat ${HOME_DIR}/config.yml) | jq 'map(.)' > ${HOME_DIR}/config.json
|
||||||
elif [ -f "${HOME_DIR}/config.yaml" ]; then
|
elif [ -f "${HOME_DIR}/config.yaml" ]; then
|
||||||
python3 -c "with open('${HOME_DIR}/config.yaml') as cy, open('${HOME_DIR}/config.json', 'w') as cj: import yaml; import json; json.dump(list(yaml.safe_load(cy).values()), cj)"
|
rq -y <<< $(cat ${HOME_DIR}/config.yaml) | jq 'map(.)' > ${HOME_DIR}/config.json
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user