From 2e77e6463ad0221c1d504fd3710f2dba297c9078 Mon Sep 17 00:00:00 2001 From: Luis Lavena Date: Sat, 27 Nov 2021 13:05:37 +0100 Subject: [PATCH] Switch dev tooling to containers Move away from local installed Crystal and use `hydrofoil-crystal` container image as runtime environment. The included `docker-compose.yml` and `Procfile.dev` files setups everything that is needed to automatically run the project's specs. To start watching for changes, in a console: $ docker compose up (Use `docker-compose` if you're still using old version of Docker Compose) You can press `Ctrl+C` to stop it or from another console: $ docker compose stop [skip ci] --- Makefile | 18 ------------------ Procfile.dev | 2 ++ docker-compose.yml | 11 +++++++++++ 3 files changed, 13 insertions(+), 18 deletions(-) delete mode 100644 Makefile create mode 100644 Procfile.dev create mode 100644 docker-compose.yml diff --git a/Makefile b/Makefile deleted file mode 100644 index d5c0632..0000000 --- a/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -CRYSTAL ?= crystal - -profile ?= ## Display profiling information after specs execution -verbose ?= ## Run specs in verbose mode - -SPEC_FLAGS := $(if $(profile),--profile )$(if $(verbose),--verbose ) - -.PHONY: default autospec spec - -default: spec - -# `autospec` task uses `watchexec` external dependency: -# https://github.com/mattgreen/watchexec -autospec: - watchexec --exts cr --watch spec --watch src --clear $(CRYSTAL) spec $(SPEC_FLAGS) - -spec: - $(CRYSTAL) spec $(SPEC_FLAGS) \ No newline at end of file diff --git a/Procfile.dev b/Procfile.dev new file mode 100644 index 0000000..d4e2a17 --- /dev/null +++ b/Procfile.dev @@ -0,0 +1,2 @@ +# watch for changes in src & spec and invoke `crystal spec`. Run only when changes are detected +autospec: watchexec -w src -w spec -f '**/*.cr' --postpone --on-busy-update=do-nothing -- crystal spec diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..68418e0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +services: + crystal: + image: ghcr.io/luislavena/hydrofoil-crystal:1.2 + command: overmind start -f Procfile.dev + working_dir: /app + + # Set these env variables using `export FIXUID=$(id -u) FIXGID=$(id -g)` + user: ${FIXUID:-1000}:${FIXGID:-1000} + + volumes: + - .:/app:cached