Skip to content

kaikiat/rust-backend

Repository files navigation

rust-backend

Getting started

  1. Use diesel-cli for postgress setup link
  2. diesel setup --database-url=postgresql://localhost:5432/leetcode
  3. diesel migration generate <NAME_OF_MIGRATION>
  4. diesel migration run
  5. diesel migration redo if errors
  6. diesel print-schema > src/schema.rs
  7. Connect to psql locally psql -h localhost -d $database_name -U $username or psql -h localhost -d leetcode -U postgres
  8. Connect via sudo -u postgres psql
  9. curl http://54.169.58.242:8080/healthz

Pipeline (Docker)

  1. Run cargo build --release --bin rust-backend first.
  2. docker build --platform linux/amd64 -t rust-backend .
  3. Tag if not tagged docker tag rust-backend kaikiatpoh/rust-backend
  4. docker push kaikiatpoh/rust-backend
  5. sudo docker logs -f kaikiatpoh/rust-backend
  6. Run as container sudo docker run -d --restart=always -p 8080:8080 kaikiatpoh/rust-backend:latest
  7. Or run as sudo docker run -d --network=host kaikiatpoh/rust-backend:latest
  8. Further optimisation DOCKER_BUILDKIT=0 docker buildx build --ulimit nofile=1024000:1024000 --platform linux/amd64 .

Database

  1. Migation. Use command below
pg_dump -d -t solutions -U postgres leetcode > leetcode.sql
  1. Next use this tool to convert to INSERT statement
cat leetcode.sql | pg-dump2insert

Others

  1. Refer to realworld-rust-rocket
  2. Refer to rust-realworld-example-app

About

Rust rocket + postgres

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published