From edc01378ec558b4ef1e2ee94a89ef7341d2b6a4c Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Fri, 26 Mar 2021 20:39:00 +0300
Subject: [PATCH] Better use ONBUILD.

---
 Dockerfile |  1 +
 README.md  | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 8cf1712..b7cbbbe 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -16,4 +16,5 @@ USER nobody
 CMD [ "supersonic", "/crontab" ]
 HEALTHCHECK CMD pgrep supersonic
 RUN supersonic -test /crontab
+ONBUILD COPY crontab /crontab
 ONBUILD RUN supersonic -test /crontab
diff --git a/README.md b/README.md
index d0d9f87..d6bf2a4 100644
--- a/README.md
+++ b/README.md
@@ -18,14 +18,16 @@ 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
-like so:
+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
-RUN apk add --update --no-cache aws-cli
-COPY crontab /crontab
 COPY script /usr/local/bin/
+USER root
+RUN apk add --update --no-cache aws-cli
+USER nobody
 ```
 
 ## License
-- 
GitLab