Open
Description
Some suggestions to Dockerfiles.md based on some of my own personal development methods.
- Use Makefiles to build / test / run
- Track changes in dependent files/artifacts so as to rebuild images when necessary
- Manage the frequently complex build, run, and management targets centrally
- Version track Makefiles alongside container code and configuration files (Dockerfiles)
- Use version-tracking ignored
.keep
files at build targets
Notional template makefile for a Docker project
IMAGE_NAME=iqtapp
DEPS=Dockerfile iqtapp.py iqtapp.config
KEEPFILE?=.imagebuild_$(IMAGE_NAME)
DOCKER_USERNAME?=erezbinyamin
PUSHTAG?=latest
build:$(KEEPFILE)
$(KEEPFILE): $(DEPS)
docker build --tag $(IMAGE_NAME) .
touch $(KEEPFILE)
rebuild:
docker build --no-cache --tag $(IMAGE_NAME) .
touch $(KEEPFILE)
bash: build
docker run -it --network host --privileged $(IMAGE_NAME) bash
clean:
docker images | grep -q "^$(IMAGE_NAME)" && docker image rm $(IMAGE_NAME) || true
rm -f $(KEEPFILE)
push:
docker tag $(IMAGE_NAME) $(DOCKER_USERNAME)/$(IMAGE_NAME):$(PUSHTAG)
docker push $(DOCKER_USERNAME)/$(IMAGE_NAME)
help:
@echo "Supported build targets:"
@echo " $(IMAGE_NAME): builds image"
@echo " build: .."
@echo " rebuild: .."
@echo " bash: launches shell inside container"
@echo " clean: removes docker image from local repository"
Metadata
Metadata
Assignees
Labels
No labels