diff --git a/.env.example b/.env.example index ebb97f85..c15161d2 100644 --- a/.env.example +++ b/.env.example @@ -14,7 +14,7 @@ MIDDLEWARE_CORS_ORIGIN=* URL_VERSIONING_ENABLE=true URL_VERSION=1 -DATABASE_URI=mongodb://localhost:27017,localhost:27018,localhost:27019/ack?retryWrites=true&w=majority&replicaSet=rs0 +DATABASE_URL=mongodb://localhost:27017,localhost:27018,localhost:27019/ack?retryWrites=true&w=majority&replicaSet=rs0 DATABASE_DEBUG=true AUTH_JWT_ISSUER=https://example.com diff --git a/README.md b/README.md index bcddecc8..aebc147a 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ _You can [request feature][ack-issues] or [report bug][ack-issues] with followin - [Database Migration and Seed](#database-migration-and-seed) - [Template Migration](#template-migration) - [Run Project](#run-project) - - [Installation dependencies with Docker](#installation-dependencies-with-docker) + - [Installation with Docker](#installation-with-docker) - [Test](#test) - [Swagger](#swagger) - [API Key](#api-key) @@ -207,16 +207,19 @@ Now you can run the project. yarn start:dev ``` -## Installation dependencies with Docker - -> Docker will install mongodb (as replication set), and redis +## Installation with Docker We need more tools to be installed. 1. [Docker][ref-docker] 2. [Docker-Compose][ref-dockercompose] -After clone this project, then run +Copy `.env.example` and change value + +1. `DATABASE_URL`: `DATABASE_URL=mongodb://host.docker.internal:27017,host.docker.internal:27018,host.docker.internal:27019/ack?retryWrites=true&w=majority&replicaSet=rs0` +2. `REDIS_HOST`: `redis` + +leave the rest as it, then run ```bash docker-compose up -d diff --git a/docker-compose.yml b/docker-compose.yml index 0cdb5094..c7e3de5d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,24 @@ name: ack services: + + apis: + build: + context: . + container_name: apis + hostname: apis + ports: + - 3000:3000 + volumes: + - ./src/:/app/src/ + - .env/:/app/.env + restart: always + networks: + - app-network + depends_on: + - redis + - mongodb1 + redis: image: redis:latest container_name: redis diff --git a/package.json b/package.json index 0c846330..5df8d4e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ack-nestjs-boilerplate", - "version": "7.1.1", + "version": "7.1.3", "description": "Ack NestJs Boilerplate", "repository": { "type": "git", diff --git a/src/configs/database.config.ts b/src/configs/database.config.ts index 2f3d4f59..56f364cc 100644 --- a/src/configs/database.config.ts +++ b/src/configs/database.config.ts @@ -4,7 +4,7 @@ export default registerAs( 'database', (): Record => ({ url: - process.env?.DATABASE_URI ?? + process.env?.DATABASE_URL ?? 'mongodb://localhost:27017,localhost:27018,localhost:27019', debug: process.env.DATABASE_DEBUG === 'true', diff --git a/test/app/dtos/app.dto.spec.ts b/test/app/dtos/app.dto.spec.ts index 834a6c34..9139979a 100644 --- a/test/app/dtos/app.dto.spec.ts +++ b/test/app/dtos/app.dto.spec.ts @@ -26,7 +26,7 @@ describe('AppEnvDto', () => { URL_VERSIONING_ENABLE: true, URL_VERSION: 1, - DATABASE_URI: faker.internet.url(), + DATABASE_URL: faker.internet.url(), DATABASE_DEBUG: false, AUTH_JWT_ISSUER: faker.internet.url(),