Added lots of documentation

master
Jef Roosens 2021-04-13 22:35:39 +02:00
parent d466ab6d13
commit 5f98b65902
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
2 changed files with 40 additions and 6 deletions

View File

@ -1,48 +1,66 @@
all: debug all: debug
.PHONY: all .PHONY: all
# Builds # 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.
debug: debug:
@ ./build -m dev -a run build @ ./build -m dev -a run build
.PHONY: debug .PHONY: debug
# 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).
release: release:
@ ./build -m rel @ ./build -m rel
.PHONY: release .PHONY: release
# This builds the release version, and pushes all relevant tags to my Docker
# Hub repository, namely chewingbever/fej
push: push:
@ ./build -m rel -a push @ ./build -m rel -a push
.PHONY: push .PHONY: push
# Run # 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.
run: run:
@ ./build -m dev -a run @ ./build -m dev -a run
.PHONY: run .PHONY: run
# As a workaround, we just have a stop command that stops the container.
stop: stop:
@ docker stop -t 2 fej @ docker stop -t 2 fej
.PHONY: stop .PHONY: stop
# This attaches to the running container, essentially giving the same result as
# just running `cargo run` locally.
logs: logs:
@ docker logs -f fej @ docker logs -f fej
.PHONY: logs .PHONY: logs
# Builds the debug version, and runs the tests (but doesn't detach).
# Testing
test: test:
@ ./build -m dev -a run -l -- test --no-fail-fast @ ./build -m dev -a run -l -- test --no-fail-fast
.PHONY: test .PHONY: test
# Runs the cargo code formatter on your code.
format: format:
@ cargo fmt @ cargo fmt
.PHONY: format .PHONY: format
# Lints your code. This also gets run in the pre-commit hook, basically
# preventing you from committing badly-formatted code.
lint: lint:
@ cargo fmt -- --check @ cargo fmt -- --check
.PHONY: lint .PHONY: lint
# This builds the documentation for the project, excluding the documentation.
# Documentation
docs: docs:
@ cargo doc --no-deps @ cargo doc --no-deps
.PHONY: docs .PHONY: docs

View File

@ -24,3 +24,19 @@ Every module has a `routes` function that returns its route macros.
## Roadmap ## Roadmap
See [roadmap.md](roadmap.md). See [roadmap.md](roadmap.md).
## Development
The entire toolchain runs on Alpine inside Docker. This makes building easier,
and (hopefully) eliminates any system-specific bugs.
A [Makefile wrapper](Makefile) is provided for ease of use. Do check it out, as
all the commands are documented for your understanding ;)
There's also the `build` script. This script does all the "heavy" lifting. It
chooses which Dockerfile to build according to the given arguments, and
generates tags for the images (useful when pushing releases). The Makefile is
really just a wrapper around this build script, allowing you to write
`make test` instead of `./build -m dev -a run test`.
tl;dr run `make run` to run your build, and `make test` to run the tests.