This guide provides instructions on how to deploy the UET Platform (Next.js Frontend, Rust API Backend, and PostgreSQL Database) to production environments using Docker and Railway.app.
Railway.app is the easiest way to deploy the UET Platform because it natively supports Nixpacks and Dockerfiles, providing automatic builds and out-of-the-box PostgreSQL with pgvector support.
- Create a new project in Railway.
- Add a new service -> Database -> Add PostgreSQL.
- IMPORTANT: Standard Railway Postgres does not have
pgvector. To use semantic search, you should instead deploy a custom Docker image for your database:- Add a new service -> Custom Service -> Deploy from Docker Image.
- Use the image:
pgvector/pgvector:pg16 - Add the necessary environment variables (
POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DB). - Add a Persistent Volume to the
/var/lib/postgresql/datapath to ensure data is saved.
- Connect your GitHub repository to Railway.
- Add a new service from your GitHub repo.
- In the service settings, go to Build -> Builder -> Dockerfile.
- Set the Dockerfile Path to
/Dockerfile.api. - Add the necessary Environment Variables:
DATABASE_URL:postgres://[USER]:[PASSWORD]@[HOST]:[PORT]/[DB_NAME]JWT_SECRET: A strong random string for user authenticationRUST_LOG:infoFRONTEND_URL: The URL where your Next.js app will be hosted
- Deploy the service. Once built, Railway will assign it a public URL (e.g.,
https://api.uet.up.railway.app).
- Add another service from the same GitHub repo.
- In the service settings, go to Build -> Builder -> Dockerfile.
- Set the Dockerfile Path to
/Dockerfile.web. - Add the necessary Environment Variables:
NEXT_PUBLIC_API_URL: The public URL of your API service (e.g.,https://api.uet.up.railway.app)
- Deploy the service. Railway will assign it a public domain for your users to access.
If you prefer hosting the platform on your own Virtual Private Server (VPS) such as AWS EC2, DigitalOcean, or Hetzner, you can use the provided docker-compose.yml.
- Ubuntu 22.04 or 24.04 recommended
- Docker Engine installed (
curl -fsSL https://get.docker.com | sh) - Docker Compose plugin installed
- At least 2GB of RAM (4GB recommended for Rust compilation)
-
Clone the repository on your server:
git clone https://github.com/unityequilibrium/UnityEquilibriumTheory.git cd UnityEquilibriumTheory -
Set up Environment Variables:
cp .env.example .env nano .env
Edit the
.envfile to add yourJWT_SECRETand updateNEXT_PUBLIC_API_URLto your server's IP or Domain. -
Build and Run:
docker-compose up --build -d
This will build the Rust API, Next.js Frontend, and pull the pgvector Database in the background.
-
Reverse Proxy (Optional but Recommended): It is highly recommended to set up Nginx or Caddy as a reverse proxy in front of your Docker containers to handle SSL/HTTPS (via Let's Encrypt).
- Point your main domain (e.g.,
uet.tech) tolocalhost:3000(Next.js) - Point your API subdomain (e.g.,
api.uet.tech) tolocalhost:3001(Rust API)
- Point your main domain (e.g.,
- View Logs:
docker-compose logs -f
- Stop Services:
docker-compose down
- Rebuild after pushing updates:
git pull docker-compose up --build -d