This is a Rust-based project that uses various libraries and frameworks to implement a messenger service.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- 🦀 Rust installed on your machine.
- 🐳 Docker to run dependant services.
- ⛽ Diesel to run and manage DB migrations.
- ⚙️ Make to run the project with
makecommands. - 🔐 Have an
Applicationconfigured in theAuthorization Serverof your choice (ex. Auth0, Okta, Google, etc).
Check configuration for further steps.
# Clone the repository
git clone https://github.com/dcadea/messenger_service.git
cd messenger_service # Navigate to the project directory
cargo build # Build the projectcargo run # Run the project
cargo watch -x run # Run the project with hot-reload
# (req: `cargo install cargo-watch`)
cargo test # Run the testsOptionally you can run the project with cargo run --release to enable optimizations.
To run the project in debug mode, you can use RUST_LOG=debug cargo run.
Or you could just use an IDE like RustRover or Zed 🚀.
cd messenger_service
docker build -t messenger_service:latest .
docker run -d -p 8000:8000 messenger_service:latestmake dev # Run the service with hot-reload locally
make image # Build the Docker image
make compose # Run the service with Docker Compose (dev mode)
make stg # Run the service with Docker Compose (stage mode)
make prod # Run the service with Docker Compose (prod mode)
make migrate # Apply diesel migrationsApplication will not start without the required environment configuration.
Optional variables have default values, but it is highly recommended to override these once you have a working setup.
- Required environment variables:
# example with Auth0 as auth server
CLIENT_ID={{your_client_id}}
CLIENT_SECRET={{your_client_secret}}
REDIRECT_URL=http://localhost:8000/callback
ISSUER=https://dcadea.auth0.com/
AUDIENCE=https://messenger.angelwing.io/api/v1
REQUIRED_CLAIMS=iss,sub,aud,exp,permissions- Optional environment variables:
# supported values: local, dev, stg, prod
ENV=local
# required for ENV=prod
SSL_CERT_FILE=/etc/ssl/certs/messenger_service_cert.pem
SSL_KEY_FILE=/etc/ssl/private/messenger_service.pem
# required for ENV=stage and ENV=prod
ALLOW_ORIGIN=https://messenger-app.domain
RUST_LOG=info
SERVICE_NAME=messenger_service
TOKEN_TTL=3600
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
POSTGRES_HOST=127.0.0.1
POSTGRES_PORT=5432
POSTGRES_DB=messenger
POSTGRES_USER={redacted}
POSTGRES_PASSWORD={redacted}
NATS_HOST=127.0.0.1
NATS_PORT=4222
MINIO_HOST=127.0.0.1
MINIO_PORT=9000
MINIO_USER={redacted}
MINIO_PASSWORD={redacted}# This will generate up.sql and down.sql in ./migrations folder
# which have to be populated with respective sql scripts.
diesel migration generate create_posts
# Once done run the following command to populate schema.rs with actual mapping
diesel migration run- Rust - The programming language used
- Cargo - The Rust package manager
- Axum - Web application framework
- Tokio - Asynchronous runtime
- htmx - Hypermedia driven web framework
- maud - HTML template engine
- PostgreSQL - Database
- Redis - In-memory data structure store
- NATS - Pub/Sub messaging system and not only :)
- minio - Object storage server
- dcadea - Initial work - dcadea
- Hat tip to anyone whose code was used
- Inspiration
- etc