diff --git a/.dockerignore b/.dockerignore index 5bb4b67..e246ba8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,4 @@ target README.md Dockerfile +docker-compose.yml diff --git a/README.md b/README.md index 8e8dd24..3cfbd3b 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,19 @@ Intrasys is an internal financial transfers application built with Rust and Axum ## Quick Start -### 1. Ensure you have rust installed -Foolow the steps described [here](https://www.rust-lang.org/tools/install) if you don't +### Using docker compose +Just run -### 2. Provision PostgreSQL Database +```bash +docker compose up +``` + +### Build locally + +#### Ensure you have rust installed +Follow the steps described [here](https://www.rust-lang.org/tools/install) if you don't + +#### Provision PostgreSQL Database The easiest way is to run a PostgreSQL container with Docker: @@ -35,7 +44,7 @@ The easiest way is to run a PostgreSQL container with Docker: docker run --name intrasys-pg -d -e POSTGRES_PASSWORD=password -p 127.0.0.1:5432:5432 postgres:alpine ``` -### 2. Run the Application +#### Run the Application ```bash cargo run @@ -87,7 +96,7 @@ The following variables affect the application behavior: - `INTRASYS_PORT` is the port the HTTP server will listen to - any of the environmental variables mentioned [here](https://docs.rs/sqlx/latest/sqlx/postgres/struct.PgConnectOptions.html#method.options) affects the postgres database connection -## Running unit tests +## Running tests Make sure you have an available postgres database and edit `DATABASE_URL` variable in the `.env` file accordingly. If you've used the docker command mentioned in the *Quickstart* section you don't need to change anything. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2106f14 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +volumes: + postgres-data: + driver: local + +services: + postgres: + image: postgres:alpine + restart: unless-stopped + environment: + - POSTGRES_PASSWORD=password + volumes: + - postgres-data:/var/lib/postgresql/data + deploy: + resources: + limits: + cpus: 1.00 + memory: 256M + healthcheck: + test: ["CMD", "pg_isready", "-U", "postgres"] + interval: 30s + timeout: 60s + retries: 5 + start_period: 5s + intrasys: + image: gitea.woggioni.net/woggioni/intrasys:latest + environment: + - PGHOST=postgres + - PGUSER=postgres + - PGPASSWORD=password + - INTRASYS_LOG=trace + ports: + - "127.0.0.1:8080:8080" + deploy: + resources: + limits: + cpus: 1.00 + memory: 32M + depends_on: + postgres: + condition: service_healthy