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]
This commit is contained in:
Luis Lavena 2021-11-27 13:05:37 +01:00
parent e2e402fcaf
commit 2e77e6463a
3 changed files with 13 additions and 18 deletions

View file

@ -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)

2
Procfile.dev Normal file
View file

@ -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

11
docker-compose.yml Normal file
View file

@ -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