From 34fd5a8726f4555f353ffa197f7ae616b59b8cb0 Mon Sep 17 00:00:00 2001 From: bretello Date: Tue, 8 Dec 2020 23:46:24 +0100 Subject: [PATCH] dev: update makefile with release target, update docs --- dev/Makefile | 27 +++++++++++++++++++++------ dev/README.md | 20 ++++++++++---------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/dev/Makefile b/dev/Makefile index 89fd01a..ef15579 100644 --- a/dev/Makefile +++ b/dev/Makefile @@ -11,7 +11,7 @@ RED="\033[31m" BLUE="\033[34m" WHITE="\033[37m" -.PHONY: test_colors clean list_targets build arch archlinux run +.PHONY: clean list_targets build build-arch build-debian arch archlinux debian run ansible release all: list_targets @@ -30,13 +30,28 @@ build-debian: Dockerfile.debian build-arch: Dockerfile.archlinux docker build -t brethil/dotfiles:dev -f Dockerfile.archlinux . -run: build clean - docker run -d --name=dotfiles-dev -v ${PWD}/..:/root/.dotfiles brethil/dotfiles:dev - echo -en ${GREEN} "***" ${CLEAR} Started container, listening on ${BOLD}${WHITE} - echo -e ${msg} `docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dotfiles-dev`:22 ${CLEAR} - echo -e ${GREEN} "***" ${CLEAR} Watching logs from the container. Hit Ctrl+C to stop watching. Run \`make clean\` to stop and remove the container +run: _run + echo -e ${GREEN} "***" ${CLEAR} Watching logs from the container. Hit Ctrl+C to stop watching. docker logs -f dotfiles-dev +_run: Dockerfile.archlinux Dockerfile.debian build clean + docker run -d --name=dotfiles-dev -v ${PWD}/..:/root/.dotfiles 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} + echo -e ${BLUE} "***" ${CLEAR} Run \`make clean\` to stop and remove the container + +ansible: ../ansible/playbooks/setup.yml _run + ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ansible-hosts -e local_development=true ../ansible/playbooks/setup.yml + +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: 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 diff --git a/dev/README.md b/dev/README.md index df0d914..2333924 100644 --- a/dev/README.md +++ b/dev/README.md @@ -13,7 +13,7 @@ make debian # this builds a docker image based on debian and runs it Start a builder in one shell: ```bash -while true; do make; done +while true; do make _run; done ``` _check for the docker IP of the started container_. @@ -41,16 +41,16 @@ the local repository bind-mounted on `/root/.dotfiles`. To use a custom volume: docker run -v :/root/dofiles` ``` -Ansible can now be used to test the installation. - -```bash -# this will install dotfiles on the docker container -ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ansible-hosts \ - -e local_development=true \ - ../ansible/playbooks/setup.yml -``` - **IMPORTANT** if bind-mounting an already existing repository, run `ansible` with `-e local_development=true` to avoid clobbering the git history if you have unpushed commit (it won't work if your repo is dirty). + +Ansible can now be used to test the installation. + + make ansible + +## Releasing + +Use `make release` to build an image from scratch, run it, install dotfiles +in the container using ansible, then commit the resulting container.