-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update local db setup guide and expose health check module (#62)
* Update local db setup guide and expose health check module * fix typing err in readme file --------- Co-authored-by: NHT <[email protected]>
- Loading branch information
1 parent
148ef1c
commit 2ed72a6
Showing
10 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# compiled output | ||
/dist | ||
/node_modules | ||
**/sql-scripts/** | ||
|
||
# Logs | ||
logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM mysql:latest | ||
|
||
# Set environment variables | ||
ENV MYSQL_ROOT_PASSWORD=mysql | ||
ENV MYSQL_DATABASE=new-2all-dev | ||
ENV MYSQL_USER=local | ||
ENV MYSQL_PASSWORD=mysql | ||
|
||
# Copy SQL files into the Docker container | ||
COPY ./sql-scripts/ /docker-entrypoint-initdb.d/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Start db with docker compose | ||
|
||
## author | ||
|
||
voanhtuanvn12 | ||
|
||
### Step 1 | ||
|
||
Ensure that there is a folder called `sql-scripts` that existed (if you want to load data) | ||
|
||
### Step 2 | ||
|
||
Make the root of terminal session at `local-db-init` | ||
|
||
``` | ||
cd local-db-init | ||
``` | ||
|
||
### Step 3 | ||
|
||
Build the docker compose | ||
|
||
``` | ||
docker compose build | ||
``` | ||
|
||
### Step 4 | ||
|
||
Run docker compose up in detach mode | ||
|
||
``` | ||
docker-compose up -d | ||
``` | ||
|
||
### Step 5 | ||
|
||
If you want to delete the mysql container | ||
|
||
``` | ||
docker-compose down | ||
``` | ||
|
||
If you also want to remove the volumes associated with the containers, you can add the -v option | ||
|
||
``` | ||
docker-compose down -v | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3.8' | ||
|
||
services: | ||
mysql: | ||
build: | ||
context: . | ||
ports: | ||
- "3306:3306" | ||
volumes: | ||
- ./sql-scripts:/docker-entrypoint-initdb.d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
|
||
@Controller('health') | ||
export class HealthCheckController { | ||
@Get() | ||
healthCheck(): string { | ||
return 'Yes, microservice is healthy'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { HealthCheckController } from './health-check.controller'; | ||
|
||
@Module({ | ||
controllers: [HealthCheckController], | ||
}) | ||
export class HealthCheckModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters