From 74dcf328aa652c742f273ee717be26fb0fd9ec76 Mon Sep 17 00:00:00 2001 From: bretello Date: Tue, 8 Dec 2020 22:06:03 +0100 Subject: [PATCH] dev: add volumes to dockerfile --- dev/Dockerfile.archlinux | 1 + dev/Dockerfile.debian | 1 + dev/README.md | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/dev/Dockerfile.archlinux b/dev/Dockerfile.archlinux index 998e427..80d2ab5 100644 --- a/dev/Dockerfile.archlinux +++ b/dev/Dockerfile.archlinux @@ -12,4 +12,5 @@ COPY id_ed25519.pub /root/.ssh/authorized_keys WORKDIR /root/ COPY entrypoint.sh / +VOLUME ["/root/.dotfiles"] CMD ["bash", "/entrypoint.sh"] diff --git a/dev/Dockerfile.debian b/dev/Dockerfile.debian index 179f1b6..da61e5e 100644 --- a/dev/Dockerfile.debian +++ b/dev/Dockerfile.debian @@ -13,4 +13,5 @@ COPY id_ed25519.pub /root/.ssh/authorized_keys WORKDIR /root/ COPY entrypoint.sh / +VOLUME ["/root/.dotfiles"] CMD ["bash", "/entrypoint.sh"] diff --git a/dev/README.md b/dev/README.md index 198d4c3..df0d914 100644 --- a/dev/README.md +++ b/dev/README.md @@ -25,3 +25,32 @@ ansible-playbook -v -i ./ansible-hosts playbooks/setup.yml ``` note: the ip address in `ansible-hosts` might have changed from `172.18.0.2`. + +## Docker images + +- Build: `make build-arch` or `make build-debian` to build the image. +- Run: `make run` to run the docker container. This bind-mounts `../` to + `/root/.dotfiles`, making it possible to test the repo in the container. + +## Docker + Ansible + +Run `dotfiles-dev` image using `make run`. This starts the container with +the local repository bind-mounted on `/root/.dotfiles`. To use a custom volume: + +```bash +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).