added docker dockercron image build environment

This commit is contained in:
Bryan Joshua Pedini 2023-04-07 13:32:46 +02:00
parent b69a9bca15
commit e82563bf3c
6 changed files with 82 additions and 1 deletions

View File

@ -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
View 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
View 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
View 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
View 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

2
versions Normal file
View File

@ -0,0 +1,2 @@
1.0-1.0:3.15
1.0-1.0:3.16