added docker dockercron image build environment
This commit is contained in:
parent
b69a9bca15
commit
e82563bf3c
28
README.md
28
README.md
@ -1 +1,27 @@
|
|||||||
# dockercron
|
# Docker DockerCron Image
|
||||||
|
A docker-based cron image that includes the docker & docker compose CLI.
|
||||||
|
|
||||||
|
## Usage:
|
||||||
|
```
|
||||||
|
docker run -v $DOCKERSOCKET:/var/run/docker.sock -v $CRONTAB:/crontab/root -v $CRONJOBS:/jobs bryanpedini/dockercron:$VERSION-$DISTRO
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example:
|
||||||
|
`crontab`:
|
||||||
|
```
|
||||||
|
* * * * * /jobs/dockerps.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
`jobs/dockerps.sh`:
|
||||||
|
```
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
docker ps -a
|
||||||
|
```
|
||||||
|
|
||||||
|
`docker` command:
|
||||||
|
```
|
||||||
|
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/crontab:/crontab/root -v $(pwd)/jobs:/jobs bryanpedini/dockercron:1.0-alpine3.16
|
||||||
|
```
|
||||||
|
|
||||||
|
## WARNING:
|
||||||
|
Pay attention to the `crontab` file permissions, ownership needs to be `0:0` for user `root`.
|
||||||
|
19
build.sh
Executable file
19
build.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (c) 2023 · Bryan Joshua Pedini
|
||||||
|
# LICENSE = gpl3
|
||||||
|
# see the LICENSE file for more details
|
||||||
|
|
||||||
|
COMPOSEVERSION="v2.17.2"
|
||||||
|
|
||||||
|
while read -r LINE; do
|
||||||
|
VERSION=$(echo "${LINE}" | sed 's/-.*//')
|
||||||
|
CRONVERSION=$(echo "${LINE}" | sed 's/.*-//;s/:.*//')
|
||||||
|
DISTRO=$(echo "${LINE}" | sed 's/.*://')
|
||||||
|
docker build \
|
||||||
|
--build-arg CRONVERSION="${CRONVERSION}" \
|
||||||
|
--build-arg DISTRO="${DISTRO}" \
|
||||||
|
--build-arg VERSION="${VERSION}" \
|
||||||
|
--build-arg COMPOSEVERSION="${COMPOSEVERSION}" \
|
||||||
|
-t bryanpedini/dockercron:"${VERSION}"-alpine"${DISTRO}" .
|
||||||
|
done < versions
|
8
crontab
Normal file
8
crontab
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# do daily/weekly/monthly maintenance
|
||||||
|
# min hour day month weekday command
|
||||||
|
|
||||||
|
# Copyright (c) 2023 · Bryan Joshua Pedini
|
||||||
|
# LICENSE = gpl3
|
||||||
|
# see the LICENSE file for more details
|
||||||
|
|
||||||
|
* * * * * echo "No cron job set, please set cron jobs, refer to the documentation"
|
8
docker-entrypoint.sh
Executable file
8
docker-entrypoint.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
# Copyright (c) 2023 · Bryan Joshua Pedini
|
||||||
|
# LICENSE = gpl3
|
||||||
|
# see the LICENSE file for more details
|
||||||
|
|
||||||
|
echo "Starting cron..."
|
||||||
|
crond -f -l 9 -c /crontab
|
18
dockerfile
Normal file
18
dockerfile
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Copyright (c) 2023 · Bryan Joshua Pedini
|
||||||
|
# LICENSE = gpl3
|
||||||
|
# see the LICENSE file for more details
|
||||||
|
|
||||||
|
ARG CRONVERSION
|
||||||
|
ARG DISTRO
|
||||||
|
FROM bryanpedini/cron:${CRONVERSION}-alpine${DISTRO}
|
||||||
|
|
||||||
|
ARG VERSION
|
||||||
|
LABEL maintainer="Bryan Joshua Pedini <b.pedini@bjphoster.com>"
|
||||||
|
LABEL version="1.0"
|
||||||
|
|
||||||
|
ARG COMPOSEVERSION
|
||||||
|
RUN apk add docker && \
|
||||||
|
mkdir -p /usr/local/lib/docker/cli-plugins && \
|
||||||
|
wget -O /usr/local/lib/docker/cli-plugins/docker-compose \
|
||||||
|
https://github.com/docker/compose/releases/download/${COMPOSEVERSION}/docker-compose-linux-x86_64 && \
|
||||||
|
chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
|
Loading…
Reference in New Issue
Block a user