Development
To set up a development environment to build this project, you'll need to install some helpful tools.
Clippy
For helpful linting rools, install Clippy
Run it with cargo
:
cargo clippy --fix
If you're using VS Code, configure the rust-analyzer
plugin to use it (in settings.json):
{
"rust-analyzer.checkOnSave.command": "clippy"
}
pre-commit
Install pre-commit to automatically set up Git hook scripts.
In Ubuntu, the package to install is pre-commit
:
sudo apt install pre-commit
In Arch Linux, sync pre-commit
:
pacman -S pre-commit
On Mac with Homebrew, the package is also pre-commit
:
brew install pre-commit
libclang
The cargo-spellcheck
utility depends on libclang
.
In Ubuntu, the package to install is libclang-dev
:
sudo apt install libclang-dev
In Arch Linux, sync clang
:
pacman -S clang
Cargo Make
To use build scripts from the Makefile.toml, install Cargo Make:
cargo install cargo-make
Run "setup" to install some tooling dependencies:
cargo make setup
Running the Local dev server
Use cargo
to run the dev server locally:
cargo make dev
Running Integration Tests
First, create a .envrc
file by copying .envrc.example
, and run direnv allow
to load the environment variables.
Then spin up the supporting Docker Compose processes:
cargo make docker up -d
Now you can reset the test DB:
cargo make db-reset
And then run the integration tests:
cargo make integration
Update Dependencies
First, install the outdated
command for cargo
:
cargo install cargo-outdated
Then, update and check for any major dependency changes:
cargo update
cargo outdated
SQLx CLI
The cargo-make setup task installs the SQLx CLI for running database migrations for the example projects.
Create a database based on the DATABASE_URL
in the .envrc
, if you haven't already:
cargo make db-create
Run migrations:
cargo make db-migrate
If you want to wipe your database and start over:
cargo make db-reset
Examples: Docker Build
To build locally, use Buildkit:
DOCKER_BUILDKIT=1 docker build -t async-graphql -f examples/async-graphql/Dockerfile .
To clear the build cache:
docker builder prune --filter type=exec.cachemount
To inspect the local filesystem:
docker run --rm -it --entrypoint=/bin/bash async-graphql
To inspect the full build context:
docker image build --no-cache -t build-context -f - . <<EOF
FROM busybox
WORKDIR /build-context
COPY . .
CMD find .
EOF
docker container run --rm build-context
And to clean up the build context test image:
docker image rm build-context