Skip to content

Instantly share code, notes, and snippets.

@finagin
Created December 31, 2025 12:56
Show Gist options
  • Select an option

  • Save finagin/8a6e5bd558846033b753e6dc9cf0efa5 to your computer and use it in GitHub Desktop.

Select an option

Save finagin/8a6e5bd558846033b753e6dc9cf0efa5 to your computer and use it in GitHub Desktop.
Base Docker scratch image as static file storage
.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