Commit 8a902ac3 authored by nimrod's avatar nimrod
Browse files

Crond image.

parent 36c8bd22
Loading
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -123,3 +123,19 @@ push-sshd:
  needs:
    - job: build-sshd
      artifacts: true

# crond image:

build-crond:
  extends: .build
  variables:
    CONTEXT: crond

push-crond:
  extends: .push
  variables:
    CONTEXT: crond
    IMAGE: cron
  needs:
    - job: build-crond
      artifacts: true

crond/.dockerignore

0 → 100644
+1 −0
Original line number Diff line number Diff line
*

crond/Dockerfile

0 → 100644
+20 −0
Original line number Diff line number Diff line
FROM alpine:3.14 as downloader
ARG URL=https://github.com/aptible/supercronic/releases/download/v0.1.12/supercronic-linux-amd64
ARG SHA1SUM=048b95b48b708983effb2e5c935a1ef8483d9e3e
WORKDIR /tmp
RUN wget -q $URL && \
    echo "$SHA1SUM  supercronic-linux-amd64" > sha1.sum && \
    sha1sum -c sha1.sum && \
    install -m 755 supercronic-linux-amd64 /usr/local/bin/supersonic && \
    touch /crontab

FROM alpine:3.14
COPY --from=downloader /usr/local/bin/supersonic /usr/local/bin/supersonic
COPY --from=downloader /crontab /crontab
WORKDIR /tmp
USER nobody
CMD [ "supersonic", "/crontab" ]
HEALTHCHECK CMD pgrep supersonic
RUN supersonic -test /crontab
ONBUILD COPY crontab /crontab
ONBUILD RUN supersonic -test /crontab

crond/README.md

0 → 100644
+29 −0
Original line number Diff line number Diff line
# Cron docker

A Docker image for running a Cron daemon, actually running
[Supersonic](https://github.com/aptible/supercronic).

## Usage

There are possible usage patterns for this image. The first is using it in a
multi-stage image build as the source of the `supersonic` binary to incorporate
in your own image like so:

```
FROM registry.shore.co.il/cron as supersonic

FROM alpine:latest
COPY --from=supersonic /usr/local/bin/supersonic /usr/local/bin/
```

The other pattern is building on top of this image to run some periodic tasks.
The `ONBUILD` commands will copy the crontab file and validate it. Just copy
whatever scripts and install whatever packages you need, like so:

```
FROM registry.shore.co.il/cron
COPY script /usr/local/bin/
USER root
RUN apk add --update --no-cache aws-cli
USER nobody
```