From b21a98f98cf2619d075fb806fb877dfe8bb0a6de Mon Sep 17 00:00:00 2001
From: Doug Bell <doug@preaction.me>
Date: Thu, 9 Jan 2020 22:21:22 -0600
Subject: [PATCH] add development images to docker-compose

This allows me to mount the src directory into the Docker container and
use Morbo to auto-restart, making development easier!
---
 Dockerfile               | 13 ++++++++-----
 Dockerfile.deploy        |  8 ++++----
 Makefile                 |  3 +++
 docker-compose.devel.yml |  6 ++++++
 4 files changed, 21 insertions(+), 9 deletions(-)
 create mode 100644 docker-compose.devel.yml

diff --git a/Dockerfile b/Dockerfile
index 1fa3aea..47adb06 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -59,16 +59,19 @@ RUN echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/s
         libdbd-mysql-perl \
         libdbd-sqlite3-perl
 
-COPY ./wait-for-it.sh ./wait-for-it.sh
-RUN chmod +x ./wait-for-it.sh
+COPY ./wait-for-it.sh /root/wait-for-it.sh
+RUN chmod +x /root/wait-for-it.sh
 
 # Add all distributions in the "dist" directory before any other
 # distributions. This way we can have pre-release modules in our dev
 # environment. Do this last to take advantage of as much caching as
 # possible above, even though any changes here mean rebuilding every
 # downstream image...
-COPY ./dist ./dist
-RUN bash -vlc 'for DIST in ./dist/*; do \
+COPY ./dist /root/dist
+RUN bash -vlc 'for DIST in /root/dist/*; do \
         echo "Building pre-release: $DIST"; \
         cpanm -v --notest $DIST; \
-    done && rm -rf ./dist'
+    done && rm -rf /root/dist'
+
+RUN mkdir /app
+WORKDIR /app
diff --git a/Dockerfile.deploy b/Dockerfile.deploy
index 55166b3..482ed54 100644
--- a/Dockerfile.deploy
+++ b/Dockerfile.deploy
@@ -1,8 +1,8 @@
 FROM cpantesters/schema
 RUN apt-get update && apt-get install -y default-mysql-client
-COPY etc/docker/deploy-db.sh ./deploy-db.sh
-COPY etc/docker/mysql.conf ./.cpanstats.cnf
-COPY var/schema/metabase-schema.sql ./metabase-schema.sql
-COPY var/schema/legacy-schema.sql ./legacy-schema.sql
+COPY etc/docker/deploy-db.sh /app/deploy-db.sh
+COPY etc/docker/mysql.conf /root/.cpanstats.cnf
+COPY var/schema/metabase-schema.sql /app/metabase-schema.sql
+COPY var/schema/legacy-schema.sql /app/legacy-schema.sql
 RUN chmod +x deploy-db.sh
 CMD [ './deploy-db.sh' ]
diff --git a/Makefile b/Makefile
index e716fbc..339f989 100644
--- a/Makefile
+++ b/Makefile
@@ -72,3 +72,6 @@ data:
 	@echo "Fetching data for $(DIST)"
 	@docker-compose run deploy cpantesters-schema fetch --dist $(DIST) report release
 
+daemon:
+	@COMPOSE_FILE="docker-compose.yml:docker-compose.devel.yml" \
+	    docker-compose build && docker-compose up
diff --git a/docker-compose.devel.yml b/docker-compose.devel.yml
new file mode 100644
index 0000000..9a0e330
--- /dev/null
+++ b/docker-compose.devel.yml
@@ -0,0 +1,6 @@
+version: '3'
+services:
+    web:
+        volumes:
+            - ./src/cpantesters-web:/app
+        command: [ "morbo", "bin/cpantesters-web" ]