2021-04-15 19:36:42 +02:00
|
|
|
all: debug logs
|
2021-03-05 20:06:17 +01:00
|
|
|
.PHONY: all
|
|
|
|
|
2021-04-13 22:35:39 +02:00
|
|
|
# Builds the debug release inside the Alpine container. For build caching, two
|
|
|
|
# volumes are used named `fej_build-cache` and `fej_registry-cache`. These
|
|
|
|
# images are automatically created for you if they don't exist. If you
|
|
|
|
# encounter any strange build errors, you can try removing this volumes to
|
|
|
|
# start a completely fresh build.
|
2021-03-05 20:06:17 +01:00
|
|
|
debug:
|
2021-04-13 21:43:30 +02:00
|
|
|
@ ./build -m dev -a run build
|
2021-03-05 20:06:17 +01:00
|
|
|
.PHONY: debug
|
|
|
|
|
2021-04-13 22:35:39 +02:00
|
|
|
# Builds the release version. In contrary to the debug version, this build
|
|
|
|
# doesn't use volumes for caching, as this would require the build to happen
|
|
|
|
# during runtime instead of during the building of the image. Instead, it uses
|
|
|
|
# the new `--mount` feature from Buildkit. This does mean that only very recent
|
|
|
|
# Docker engines can build the release version (in my case, at the time of
|
|
|
|
# writing this, 20.10.5).
|
2021-03-05 20:06:17 +01:00
|
|
|
release:
|
2021-04-12 17:39:52 +02:00
|
|
|
@ ./build -m rel
|
2021-03-05 20:06:17 +01:00
|
|
|
.PHONY: release
|
|
|
|
|
2021-04-13 22:35:39 +02:00
|
|
|
# This builds the release version, and pushes all relevant tags to my Docker
|
|
|
|
# Hub repository, namely chewingbever/fej
|
2021-03-23 09:37:18 +01:00
|
|
|
push:
|
2021-04-13 22:09:50 +02:00
|
|
|
@ ./build -m rel -a push
|
2021-03-21 16:29:53 +01:00
|
|
|
.PHONY: push
|
2021-03-05 20:06:17 +01:00
|
|
|
|
2021-04-13 22:35:39 +02:00
|
|
|
# This builds the debug release, and runs it detached. The reason we detach the
|
|
|
|
# container is because Rocket has a tendency to ignore ctlr-c when inside a
|
|
|
|
# container, which gets annoying really fast.
|
2021-03-05 20:06:17 +01:00
|
|
|
run:
|
2021-04-12 17:39:52 +02:00
|
|
|
@ ./build -m dev -a run
|
2021-03-05 23:34:38 +01:00
|
|
|
.PHONY: run
|
2021-03-05 20:40:49 +01:00
|
|
|
|
2021-04-13 22:35:39 +02:00
|
|
|
# As a workaround, we just have a stop command that stops the container.
|
2021-04-12 17:39:52 +02:00
|
|
|
stop:
|
|
|
|
@ docker stop -t 2 fej
|
2021-04-15 17:21:32 +02:00
|
|
|
@ docker stop fej_db
|
2021-04-12 17:39:52 +02:00
|
|
|
.PHONY: stop
|
|
|
|
|
2021-04-13 22:35:39 +02:00
|
|
|
# This attaches to the running container, essentially giving the same result as
|
|
|
|
# just running `cargo run` locally.
|
2021-04-12 17:39:52 +02:00
|
|
|
logs:
|
|
|
|
@ docker logs -f fej
|
|
|
|
.PHONY: logs
|
|
|
|
|
2021-04-15 17:21:32 +02:00
|
|
|
# This just starts up a shell inside the fej container
|
|
|
|
sh:
|
|
|
|
@ docker exec -it fej sh
|
|
|
|
.PHONY: sh
|
|
|
|
|
2021-04-15 18:05:02 +02:00
|
|
|
# Starts a psql session in the database container
|
|
|
|
dbsh:
|
|
|
|
@ docker exec -it fej_db psql -U fej -d fej
|
|
|
|
|
2021-04-13 22:35:39 +02:00
|
|
|
# Builds the debug version, and runs the tests (but doesn't detach).
|
2021-03-05 23:34:38 +01:00
|
|
|
test:
|
2021-04-12 17:39:52 +02:00
|
|
|
@ ./build -m dev -a run -l -- test --no-fail-fast
|
2021-03-05 23:34:38 +01:00
|
|
|
.PHONY: test
|
2021-03-11 20:52:30 +01:00
|
|
|
|
2021-04-13 22:35:39 +02:00
|
|
|
# Runs the cargo code formatter on your code.
|
2021-04-02 21:20:36 +02:00
|
|
|
format:
|
|
|
|
@ cargo fmt
|
|
|
|
.PHONY: format
|
|
|
|
|
2021-04-13 22:35:39 +02:00
|
|
|
# Lints your code. This also gets run in the pre-commit hook, basically
|
|
|
|
# preventing you from committing badly-formatted code.
|
2021-04-04 09:57:19 +02:00
|
|
|
lint:
|
|
|
|
@ cargo fmt -- --check
|
|
|
|
.PHONY: lint
|
|
|
|
|
2021-04-13 22:35:39 +02:00
|
|
|
# This builds the documentation for the project, excluding the documentation.
|
2021-03-11 20:52:30 +01:00
|
|
|
docs:
|
|
|
|
@ cargo doc --no-deps
|
|
|
|
.PHONY: docs
|
2021-04-15 19:36:42 +02:00
|
|
|
|
|
|
|
# This recipe removes all chewingbever/fej images from your system
|
|
|
|
clean-images:
|
|
|
|
@ docker images | grep '^chewingbever/fej' | sed 's/ \+/ /g' | cut -f3 -d' ' | xargs docker rmi
|