mirror of
https://github.com/willfarrell/docker-crontab.git
synced 2025-04-19 12:49:48 +02:00
chore: move build to the repo rather than the dockerfiles repo.
This commit is contained in:
parent
ccaf6059e7
commit
e3bfdebe5d
3
.github/FUNDING.yml
vendored
Normal file
3
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
github: [SimplicityGuy]
|
||||||
|
ko_fi: robertwlodarczyk
|
||||||
|
custom: [paypal.me/RWlodarczyk]
|
75
.github/workflows/build.yml
vendored
Normal file
75
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
---
|
||||||
|
name: crontab
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
schedule:
|
||||||
|
- cron: '0 1 * * 6'
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.actor }}/crontab
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-crontab:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository.
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Log in to the GitHub Container Registry.
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker.
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=schedule,pattern={{date 'YYYYMMDD'}}
|
||||||
|
|
||||||
|
- name: Set up QEMU.
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx.
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64, linux/arm64
|
||||||
|
|
||||||
|
- name: Build and push Docker image to GitHub Container Registry.
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64, linux/arm64
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
provenance: true
|
||||||
|
sbom: true
|
||||||
|
|
||||||
|
- name: Send notification to Discord.
|
||||||
|
uses: sarisia/actions-status-discord@v1.12.0
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
32
.pre-commit-config.yaml
Normal file
32
.pre-commit-config.yaml
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.4.0
|
||||||
|
hooks:
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-shebang-scripts-are-executable
|
||||||
|
- id: check-yaml
|
||||||
|
- id: detect-aws-credentials
|
||||||
|
- id: detect-private-key
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: mixed-line-ending
|
||||||
|
- id: trailing-whitespace
|
||||||
|
|
||||||
|
- repo: https://github.com/python-jsonschema/check-jsonschema
|
||||||
|
rev: 0.23.2
|
||||||
|
hooks:
|
||||||
|
- id: check-github-workflows
|
||||||
|
|
||||||
|
- repo: https://github.com/executablebooks/mdformat
|
||||||
|
rev: 0.7.16
|
||||||
|
hooks:
|
||||||
|
- id: mdformat
|
||||||
|
additional_dependencies:
|
||||||
|
- mdformat-gfm
|
||||||
|
|
||||||
|
- repo: https://github.com/hadolint/hadolint
|
||||||
|
rev: v2.12.1-beta
|
||||||
|
hooks:
|
||||||
|
- id: hadolint
|
40
Dockerfile
40
Dockerfile
@ -1,23 +1,44 @@
|
|||||||
FROM alpine:latest as rq-build
|
#hadolint ignore=DL3007
|
||||||
|
FROM alpine:latest as builder
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.title="crontab builder" \
|
||||||
|
org.opencontainers.image.description="crontab builder" \
|
||||||
|
org.opencontainers.image.authors="robert@simplicityguy.com" \
|
||||||
|
org.opencontainers.image.source="https://github.com/SimplicityGuy/alertmanager-discord/blob/main/Dockerfile" \
|
||||||
|
org.opencontainers.image.licenses="MIT" \
|
||||||
|
org.opencontainers.image.created="$(date +'%Y-%m-%d')" \
|
||||||
|
org.opencontainers.image.base.name="docker.io/library/alpine"
|
||||||
|
|
||||||
ENV RQ_VERSION=1.0.2
|
ENV RQ_VERSION=1.0.2
|
||||||
WORKDIR /usr/bin/rq/
|
WORKDIR /usr/bin/rq/
|
||||||
|
|
||||||
RUN apk update && \
|
#hadolint ignore=DL3018
|
||||||
apk upgrade && \
|
RUN apk update --quiet --no-cache && \
|
||||||
apk add --no-cache \
|
apk upgrade --quiet --no-cache && \
|
||||||
|
apk add --quiet --no-cache \
|
||||||
upx && \
|
upx && \
|
||||||
wget https://github.com/dflemstr/rq/releases/download/v${RQ_VERSION}/rq-v${RQ_VERSION}-x86_64-unknown-linux-musl.tar.gz && \
|
rm /var/cache/apk/* && \
|
||||||
|
wget --quiet https://github.com/dflemstr/rq/releases/download/v${RQ_VERSION}/rq-v${RQ_VERSION}-x86_64-unknown-linux-musl.tar.gz && \
|
||||||
tar -xvf rq-v${RQ_VERSION}-x86_64-unknown-linux-musl.tar.gz && \
|
tar -xvf rq-v${RQ_VERSION}-x86_64-unknown-linux-musl.tar.gz && \
|
||||||
upx --brute rq
|
upx --brute rq
|
||||||
|
|
||||||
|
#hadolint ignore=DL3007
|
||||||
FROM docker:latest as release
|
FROM docker:latest as release
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.title="crontab" \
|
||||||
|
org.opencontainers.image.description="A docker job scheduler (aka crontab for docker)." \
|
||||||
|
org.opencontainers.image.authors="robert@simplicityguy.com" \
|
||||||
|
org.opencontainers.image.source="https://github.com/SimplicityGuy/docker-crontab/blob/main/Dockerfile" \
|
||||||
|
org.opencontainers.image.licenses="MIT" \
|
||||||
|
org.opencontainers.image.created="$(date +'%Y-%m-%d')" \
|
||||||
|
org.opencontainers.image.base.name="docker.io/library/docker"
|
||||||
|
|
||||||
ENV HOME_DIR=/opt/crontab
|
ENV HOME_DIR=/opt/crontab
|
||||||
|
|
||||||
RUN apk update && \
|
#hadolint ignore=DL3018
|
||||||
apk upgrade && \
|
RUN apk update --quiet --no-cache && \
|
||||||
apk add --no-cache \
|
apk upgrade --quiet --no-cache && \
|
||||||
|
apk add --quiet --no-cache \
|
||||||
bash \
|
bash \
|
||||||
coreutils \
|
coreutils \
|
||||||
curl \
|
curl \
|
||||||
@ -25,11 +46,12 @@ RUN apk update && \
|
|||||||
jq \
|
jq \
|
||||||
tini \
|
tini \
|
||||||
wget && \
|
wget && \
|
||||||
|
rm /var/cache/apk/* && \
|
||||||
mkdir -p ${HOME_DIR}/jobs && \
|
mkdir -p ${HOME_DIR}/jobs && \
|
||||||
rm -rf /etc/periodic /etc/crontabs/root && \
|
rm -rf /etc/periodic /etc/crontabs/root && \
|
||||||
adduser -S docker -D
|
adduser -S docker -D
|
||||||
|
|
||||||
COPY --from=rq-build /usr/bin/rq/rq /usr/local/bin
|
COPY --from=builder /usr/bin/rq/rq /usr/local/bin
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
|
|
||||||
ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"]
|
ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"]
|
||||||
|
23
README.md
23
README.md
@ -1,12 +1,16 @@
|
|||||||
# crontab
|
# crontab
|
||||||
|
|
||||||
|
  [](https://github.com/pre-commit/pre-commit)
|
||||||
|
|
||||||
A simple wrapper over `docker` to all complex cron job to be run in other containers.
|
A simple wrapper over `docker` to all complex cron job to be run in other containers.
|
||||||
|
|
||||||
## Why?
|
## Why?
|
||||||
|
|
||||||
Yes, I'm aware of [mcuadros/ofelia](https://github.com/mcuadros/ofelia) (>250MB when this was created), it was the main inspiration for this project.
|
Yes, I'm aware of [mcuadros/ofelia](https://github.com/mcuadros/ofelia) (>250MB when this was created), it was the main inspiration for this project.
|
||||||
A great project, don't get me wrong. It was just missing certain key enterprise features I felt were required to support where docker is heading.
|
A great project, don't get me wrong. It was just missing certain key enterprise features I felt were required to support where docker is heading.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Easy to read schedule syntax allowed.
|
- Easy to read schedule syntax allowed.
|
||||||
- Allows for comments, cause we all need friendly reminders of what `update_script.sh` actually does.
|
- Allows for comments, cause we all need friendly reminders of what `update_script.sh` actually does.
|
||||||
- Start an image using `image`.
|
- Start an image using `image`.
|
||||||
@ -15,6 +19,7 @@ A great project, don't get me wrong. It was just missing certain key enterprise
|
|||||||
- Ability to share settings between cron jobs using `~~shared-settings` as a key.
|
- Ability to share settings between cron jobs using `~~shared-settings` as a key.
|
||||||
|
|
||||||
## Config file
|
## Config file
|
||||||
|
|
||||||
The config file can be specified in any of `json`, `toml`, or `yaml`, and can be defined as either an array or mapping (top-level keys will be ignored; can be useful for organizing commands)
|
The config file can be specified in any of `json`, `toml`, or `yaml`, and can be defined as either an array or mapping (top-level keys will be ignored; can be useful for organizing commands)
|
||||||
|
|
||||||
- `name`: Human readable name that will be used as the job filename. Will be converted into a slug. Optional.
|
- `name`: Human readable name that will be used as the job filename. Will be converted into a slug. Optional.
|
||||||
@ -54,6 +59,7 @@ See [`config-samples`](config-samples) for examples.
|
|||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
### Command Line
|
### Command Line
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build -t crontab .
|
docker build -t crontab .
|
||||||
docker run -d \
|
docker run -d \
|
||||||
@ -65,16 +71,18 @@ docker run -d \
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Use with docker-compose
|
### Use with docker-compose
|
||||||
|
|
||||||
1. Figure out which network name used for your docker-compose containers
|
1. Figure out which network name used for your docker-compose containers
|
||||||
* use `docker network ls` to see existing networks
|
- use `docker network ls` to see existing networks
|
||||||
* if your `docker-compose.yml` is in `my_dir` directory, you probably has network `my_dir_default`
|
- if your `docker-compose.yml` is in `my_dir` directory, you probably has network `my_dir_default`
|
||||||
* otherwise [read the docker-compose docs](https://docs.docker.com/compose/networking/)
|
- otherwise [read the docker-compose docs](https://docs.docker.com/compose/networking/)
|
||||||
2. Add `dockerargs` to your docker-crontab `config.json`
|
1. Add `dockerargs` to your docker-crontab `config.json`
|
||||||
* use `--network NETWORK_NAME` to connect new container into docker-compose network
|
- use `--network NETWORK_NAME` to connect new container into docker-compose network
|
||||||
* use `--name NAME` to use named container
|
- use `--name NAME` to use named container
|
||||||
* e.g. `"dockerargs": "--it"`
|
- e.g. `"dockerargs": "--it"`
|
||||||
|
|
||||||
### Dockerfile
|
### Dockerfile
|
||||||
|
|
||||||
```Dockerfile
|
```Dockerfile
|
||||||
FROM registry.gitlab.com/simplicityguy/docker/crontab
|
FROM registry.gitlab.com/simplicityguy/docker/crontab
|
||||||
|
|
||||||
@ -82,6 +90,7 @@ COPY config.json ${HOME_DIR}/
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Logrotate Dockerfile
|
### Logrotate Dockerfile
|
||||||
|
|
||||||
```Dockerfile
|
```Dockerfile
|
||||||
FROM registry.gitlab.com/simplicityguy/docker/crontab
|
FROM registry.gitlab.com/simplicityguy/docker/crontab
|
||||||
|
|
||||||
|
@ -47,4 +47,3 @@ onstart = true
|
|||||||
command = "sh -c '/etc/scripts/make_hpkp ${NGINX_DOMAIN} && /usr/sbin/nginx -t && /usr/sbin/nginx -s reload'"
|
command = "sh -c '/etc/scripts/make_hpkp ${NGINX_DOMAIN} && /usr/sbin/nginx -t && /usr/sbin/nginx -s reload'"
|
||||||
project = "conduit"
|
project = "conduit"
|
||||||
container = "nginx"
|
container = "nginx"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user