This project utilizes Rust with the Axum v0.7 framework along with the Prisma Client Rust to build a realworld application. For Prisma Client Rust ORM, refer to Prisma and Prisma Client Rust Repository for more information.
Check other implementaion of example apps in Codebaseshow. For more information on how to this works with other frontends/backends, head over to the RealWorld repo.
Make sure you have the following installed:
- Rust
- Docker
- MySQL
- Clone this repository.
- Set up your environment variables by creating a
.envfile in the root directory. Use the provided examples in the README as a guide. - Ensure your MySQL server is running.
- Apply migrations
- Generate Prisma Client
If you want to use other databases, you need to change the database URL in the .env file and change database provider in schema.prisma file. For more information check out Docs.
You can use the provided justfile for various commands:
just setup: Apply migrations usingprisma-cli.just generate: Generate the Prisma Client usingprisma-cli.just run: Run the application usingcargo run.just watch: Usecargo watchto automatically reload the application on file changes.just build: Build the application using the development profile.just release: Build the application for release.just test: Run tests usingcargo test.
If you prefer Docker, follow these steps:
-
Build the Docker image:
The Dockerfile includes steps to build the project within a Docker container. Particularly, the
cargo prisma generatecommand is used to generate the Prisma Client during the Docker image build process. This command parses the Prisma schema and creates a client tailored to the defined database structure.docker-compose build
-
Start the containers:
docker-compose up
Ensure your environment variables are appropriately set. Here are some examples:
DATABASE_URL: MySQL database URL.PORT: Port on which the application runs.RUST_LOG: Rust logging level.JWT_SECRET: Secret key for JWT authentication.MYSQL_ROOT_PASSWORD: If using docker-compose make sure to set MySQL root password.
This project cannot be built in release mode using Rust stable toolchain version 1.7.4 (stable-aarch64-apple-darwin) due to a compilation error with the psl-core library. However, it can be successfully built in debug mode using this toolchain.
Contributions are welcome! Feel free to open issues or pull requests.
This project is licensed under the MIT License.
