Docker makefile
Jump to navigation
Jump to search
Kontainerių docker-compose.yml failai pervadinami į servisas.yml ir startuojami komanda
make up servisas
Kitos komandos
make down servisas # išjungia ir pašalina servisą make update servisas # atnaujina veikiantį servisą ir užkrauna iš naujo make verify servisas # patikrina serviso yml failą make logs servisas # rodo serviso žurnalą (realiu laiku) make build servisas # buildina servisą make down_all # išjungia visus servisus aprašytus esamosios direktorijos yml failuose make up_all # pakelia visus servisus aprašytus esamoje direktorijoje yml failuose make clear_logs # išvalo visų konteinerių log failus make clean # išvalo nenaudojamus image/volumes/networks ir t.t.
YML_FILES := $(wildcard *.yml)
all: help
help:
@echo "Use make up <name>"
@echo "Use make down <name>"
update:
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower --cleanup --run-once --debug --include-stopped $(filter-out $@,$(MAKECMDGOALS))
verify:
COMPOSE_PROJECT_NAME=$(filter-out $@,$(MAKECMDGOALS)) COMPOSE_IGNORE_ORPHANS=True docker-compose -f $(filter-out $@,$(MAKECMDGOALS)).yml config
build:
COMPOSE_PROJECT_NAME=$(filter-out $@,$(MAKECMDGOALS)) COMPOSE_IGNORE_ORPHANS=True docker-compose -f $(filter-out $@,$(MAKECMDGOALS)).yml build --no-cache
logs:
docker logs $(filter-out $@,$(MAKECMDGOALS)) -f
up:
@COMPOSE_PROJECT_NAME=$(filter-out $@,$(MAKECMDGOALS)) COMPOSE_IGNORE_ORPHANS=True docker-compose -f $(filter-out $@,$(MAKECMDGOALS)).yml up -d
down:
@COMPOSE_PROJECT_NAME=$(filter-out $@,$(MAKECMDGOALS)) COMPOSE_IGNORE_ORPHANS=True docker-compose -f $(filter-out $@,$(MAKECMDGOALS)).yml down
down_all:
@for f in $(YML_FILES); do \
COMPOSE_PROJECT_NAME=$$(echo $${f} | cut -d '.' -f1) COMPOSE_IGNORE_ORPHANS=True docker-compose -f $${f} down; \
done
up_all:
@for f in $(YML_FILES); do \
COMPOSE_PROJECT_NAME=$$(echo $${f} | cut -d '.' -f1) COMPOSE_IGNORE_ORPHANS=True docker-compose -f $${f} up -d; \
done
test:
@for f in $(YML_FILES); do \
echo "File: $${f} split name: $$(echo $${f} | cut -d '.' -f1)"; \
done
clear_logs:
@for f in $(YML_FILES); do \
docker_clear_logs $$(echo $${f} | cut -d '.' -f1); \
done
clean:
docker image prune -a -f
docker volume prune -f
docker network prune -f
docker system prune --volumes -f
%: # thanks to chakrit
@: # thanks to William Pursell