# Build and Deploy Steps

## A. Running Locally without Docker <a href="#clone-repository" id="clone-repository"></a>

### Clone repository <a href="#clone-repository" id="clone-repository"></a>

{% code overflow="wrap" %}

```bash
# Fork and Clone the Repository
git clone git@github.com:PSMRI/ubi-wallet-backend.git
cd ubi-wallet-backend

# Check out the main branch
git checkout main
```

{% endcode %}

### Install  Dependencies

```bash
# Install dependencies
npm install
```

### Optional - Set up Git hooks

```bash
# Set up Git hooks (Husky)
npm run prepare
git config core.hooksPath .husky/_
chmod +x .husky/pre-commit
chmod +x .husky/commit-msg
```

### Create / Update .env

Ensure you have created and updated `.env` with required variables

### Running in Dev Mode

```bash
npm run start:dev
```

The backend will be available at: 👉 [http://localhost:3018](http://localhost:3018/)

### Running in Production Mode

```bash
npm run build
npm run start:prod
```

## B. Running with Docker <a href="#clone-repository" id="clone-repository"></a>

### Create / Update .env

Ensure you have created and updated `.env` with required variables

### Build Docker Image Run Steps

Using [Dockerfile](https://github.com/PSMRI/ubi-beneficiary-backend/blob/main/Dockerfile) from the repo code, you can generate an image

```bash
# Build the Docker Image
docker build -t wallet-backend .
```

### Example .env for docker

The `docker-compose.yml` requires a separate file `.env`&#x20;

{% code overflow="wrap" %}

```bash
# SERVER CONFIGURATION
PORT=3018
NODE_ENV=development

# WALLET PROVIDER CONFIGURATION
WALLET_PROVIDER=dhiway

# DHIWAY WALLET API CONFIGURATION
DHIWAY_API_BASE=https://dhiway-api-url.example.in
DHIWAY_API_KEY=your-dhiway-api-key-here
DHIWAY_VC_ISSUER_INSTANCE_URI=https://vc-issuer.example.in
DHIWAY_VC_ISSUER_GET_VC_BASE_URI=https://vc-issuer.example.in/vc
DHIWAY_WATCHER_EMAIL=watcher@example.in

# WALLET SERVICE CONFIGURATION
WALLET_SERVICE_BASE_URL=http://localhost:3018

# DATABASE CONFIGURATION
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=secure-password-here
DB_DATABASE=wallet_db

# CORS CONFIGURATION
ALLOWED_ORIGINS=http://localhost:3000,https://app.example.in

# SECURITY CONFIGURATION
HOUSEKEEPING_SECRET_KEY=your-super-secret-housekeeping-key-here
```

{% endcode %}

### Use Image in docker-compose

Use generated images in [docker-compose.yml](https://github.com/PSMRI/ubi-wallet-backend/blob/main/docker-compose.yml)

```bash
# Run the Container
docker-compose up -d
```

### More about docker-compose

The [docker-compose.yml](https://github.com/PSMRI/ubi-wallet-backend/blob/main/docker-compose.yml) located in the **root of the repository** provisions the following services as well:

* **Postgres** (port `5432`)

#### Verify Services

* Database: `localhost:5432`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://piramal-swasthya.gitbook.io/uba/toasters/wallet-toaster/developer-guide/backend-guide/build-and-deploy-steps.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
