- Use diesel-cli for postgress setup link
diesel setup --database-url=postgresql://localhost:5432/leetcode
diesel migration generate <NAME_OF_MIGRATION>
diesel migration run
diesel migration redo
if errorsdiesel print-schema > src/schema.rs
- Connect to psql locally psql -h localhost -d $database_name -U $username or psql -h localhost -d leetcode -U postgres
- Connect via
sudo -u postgres psql
- curl http://54.169.58.242:8080/healthz
- Run
cargo build --release --bin rust-backend
first. - docker build --platform linux/amd64 -t rust-backend .
- Tag if not tagged docker tag rust-backend kaikiatpoh/rust-backend
- docker push kaikiatpoh/rust-backend
- sudo docker logs -f kaikiatpoh/rust-backend
- Run as container
sudo docker run -d --restart=always -p 8080:8080 kaikiatpoh/rust-backend:latest
- Or run as
sudo docker run -d --network=host kaikiatpoh/rust-backend:latest
- Further optimisation
DOCKER_BUILDKIT=0 docker buildx build --ulimit nofile=1024000:1024000 --platform linux/amd64 .
- Migation. Use command below
pg_dump -d -t solutions -U postgres leetcode > leetcode.sql
- Next use this tool to convert to INSERT statement
cat leetcode.sql | pg-dump2insert
- Refer to realworld-rust-rocket
- Refer to rust-realworld-example-app