Created
December 31, 2025 12:56
-
-
Save finagin/8a6e5bd558846033b753e6dc9cf0efa5 to your computer and use it in GitHub Desktop.
Base Docker scratch image as static file storage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .DEFAULT_GOAL := app | |
| .ONESHELL: | |
| .PHONEY: app clean | |
| EXECUTOR := $(shell which docker || which podman) | |
| %: %.image | |
| $(EXECUTOR) run --rm vendor/$* | |
| $(EXECUTOR) history vendor/$* | |
| @$(MAKE) clean | |
| %.image: Dockerfile.% | |
| $(EXECUTOR) build --no-cache -t vendor/$* -f Dockerfile.$* . | |
| Dockerfile.app: donor.image | |
| @echo 'FROM alpine:3.21' > $@ | |
| @echo 'COPY --from=vendor/donor /out/data/*.txt /usr/data/' >> $@ | |
| @echo 'ENTRYPOINT ["sh", "-lc", "cat /usr/data/*.txt"]' >> $@ | |
| Dockerfile.donor: first.txt second.txt | |
| @echo "FROM scratch" > $@ | |
| @echo "COPY ./*.txt /out/data/" >> $@ | |
| %.txt: | |
| @echo "$* file data" > $@ | |
| clean: | |
| @$(EXECUTOR) rmi -f vendor/app vendor/donor > /dev/null 2>&1 || true | |
| @rm *.txt Dockerfile.* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment