1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-09 21:41:31 +01:00
dotfiles/dev/Makefile

Failed to ignore revisions in .git-blame-ignore-revs.

69 lines
2.6 KiB
Makefile
Raw Normal View History

SHELL=/bin/bash
2020-12-08 18:17:20 +01:00
ifndef VERBOSE
.SILENT:
endif
CLEAR="\033[0m"
BOLD="\033[1m"
GREEN="\033[32m"
RED="\033[31m"
BLUE="\033[34m"
WHITE="\033[37m"
.PHONY: clean list_targets build build-arch build-debian arch archlinux debian run ansible release
2020-12-08 18:17:20 +01:00
all: list_targets
list_targets:
echo "List of targets:"
@grep '^[^#[:space:]].*:' Makefile
debian: clean build-debian run
arch archlinux: clean build-arch run
2020-12-08 18:17:20 +01:00
build: build-arch
build-debian: Dockerfile.debian
2024-07-04 12:21:21 +02:00
docker build -t brethil/dotfiles:dev -f Dockerfile.debian ..
2020-12-08 18:17:20 +01:00
build-arch: Dockerfile.archlinux
2024-07-04 12:21:21 +02:00
docker build -t brethil/dotfiles:dev -f Dockerfile.archlinux ..
run: _run
echo -e ${GREEN} "***" ${CLEAR} Watching logs from the container. Hit Ctrl+C to stop watching.
docker logs -f dotfiles-dev
2024-07-04 12:21:21 +02:00
_run: clean build
# docker run -d --rm --name=dotfiles-dev -v ${PWD}/..:/root/.dotfiles:ro brethil/dotfiles:dev
docker run -d --rm --name=dotfiles-dev brethil/dotfiles:dev
echo -en ${GREEN} "***" ${CLEAR} Started container, listening on
echo -e ${BOLD}${WHITE} `docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dotfiles-dev`:22 ${CLEAR}
2024-07-04 12:21:21 +02:00
echo -e ${BLUE} "***" ${CLEAR} Run \`make clean\` to stop and remove the container, \`make run\` to check the logs.
2024-07-04 12:21:21 +02:00
ansible: SHELL:=/bin/bash
ansible: ../playbook.yml _run
@ip_address=$$(docker inspect dotfiles-dev --format '{{.NetworkSettings.IPAddress}}'); \
if [[ -z "$$ip_address" ]]; then \
echo "ip address is not defined, is your container running?" >&2; \
exit 1; \
else \
sed -i "s/172.18.0.2/$$ip_address/" ansible-hosts; \
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ansible-hosts ../playbook.yml; \
fi
release: build-arch ansible
docker commit -m "install and initialize dotfiles (ansible)" dotfiles-dev brethil/dotfiles:latest
docker tag brethil/dotfiles:latest brethil/dotfiles:`git rev-parse --short HEAD &2>/dev/null`
echo -e ${GREEN} "***" ${CLEAR} committed and tagged the \"dockerfiles-dev\" to brethil/dotfiles:latest and :`git rev-parse HEAD --short`
if ! git diff --quiet --exit-code; then \
docker tag brethil/dotfiles:latest brethil/dotfiles:dev && \
echo -e ${GREEN} "***" ${CLEAR} committed and tagged the \"dockerfiles-dev\" to brethil/dotfiles:dev; \
fi
clean:
2020-12-08 18:17:20 +01:00
echo -e ${GREEN} "***" ${CLEAR} Stopping and removing \"dockerfiles-dev\" container...
docker kill dotfiles-dev &>/dev/null &>/dev/null && echo -e ${GREEN} "***" ${CLEAR} Killed container: dotfiles-dev || echo -e ${BLUE} "***" ${CLEAR} no containers to stop
2024-07-04 12:21:21 +02:00
docker stop dotfiles-dev &>/dev/null && echo -e ${GREEN} "***" ${CLEAR} Removed container: dotfiles-dev || echo -e ${BLUE} "***" ${CLEAR} no containers to remove