Skip to content

Commit ef4f470

Browse files
committed
fix: add .env_sample file with initial configuration
1 parent 64d802a commit ef4f470

File tree

5 files changed

+44
-9
lines changed

5 files changed

+44
-9
lines changed

.env_sample

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
JWT_SECRET=vitabletech-secret-key
2+
PORT=5000
3+
DB_HOST=db
4+
DB_USER=root
5+
DB_PASSWORD=notSecureChangeMe
6+
DB_NAME=testdb
7+
DB_DIALECT=mysql
8+
DB_POOL_MAX=5
9+
DB_POOL_MIN=0
10+
DB_POOL_ACQUIRE=30000
11+
DB_POOL_IDLE=10000
12+
NODE_ENV=development
13+
APP_PORT=80
14+
PHPMYADMIN_PORT=8081
15+
16+
GIT_USERNAME=msrajawat298

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ git clone https://github.com/vitabletech/node-express-api-bootstrap.git
2222
cd node-express-api-bootstrap
2323
```
2424

25-
3. Edit the `.env` file to configure your environment variables. You may also need to adjust the `docker-compose.yml` file if you wish to use non-default settings.
25+
3. Rename `.env_sample` to .env andEdit the `.env` file to configure your environment variables. You may also need to adjust the `docker-compose.yml` file if you wish to use non-default settings.
2626

2727
## Running the Application
2828

@@ -45,14 +45,14 @@ docker exec -it vitabletech-node-app /bin/bash
4545
5. Inside the container, run the following command to synchronize the database:
4646

4747
```bash
48-
npm run sync-db
48+
npm run sync-db && npm run seed
4949
```
5050

5151
This command will automatically create the required tables.
5252

5353
6. Once the database synchronization is complete, you can start working on the application.
5454

55-
7. Access the Node.js application at [http://localhost:3000/](http://localhost:3000/).
55+
7. Access the Node.js application at [http://localhost/](http://localhost/).
5656

5757
## Enjoy!
5858

config/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"username": "root",
44
"password": "notSecureChangeMe",
55
"database": "testdb",
6-
"host": "localhost",
6+
"host": "db",
77
"dialect": "mysql",
88
"logging": "console.log"
99
},

docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ services:
77
volumes:
88
- .:/app
99
working_dir: /app
10-
command: bash -c "npm install && npm run dev"
10+
command: bash -c "chmod +x ./setup.sh && ./setup.sh"
1111
ports:
12-
- 3000:3000
12+
- "${APP_PORT}:${PORT}" # Use the port number defined in .env for the host
1313
env_file:
1414
- .env
1515

@@ -20,15 +20,15 @@ services:
2020
ports:
2121
- 3306:3306
2222
environment:
23-
MYSQL_ROOT_PASSWORD: notSecureChangeMe
23+
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
2424

2525
phpmyadmin:
2626
container_name: vitabletech-phpmyadmin
2727
image: phpmyadmin
2828
restart: always
2929
ports:
30-
- 8080:80
30+
- ${PHPMYADMIN_PORT}:80
3131
environment:
3232
PMA_ARBITRARY: 1
3333
PMA_USER: root
34-
PMA_PASSWORD: notSecureChangeMe
34+
PMA_PASSWORD: ${DB_PASSWORD}

setup.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
4+
# Set up Git
5+
git config --global user.email $GIT_EMAIL
6+
git config --global user.name $GIT_USERNAME
7+
8+
# Install dependencies
9+
npm install
10+
11+
# Run the appropriate command based on the NODE_ENV variable
12+
if [[ $NODE_ENV == 'development' ]]; then
13+
npm run dev
14+
else
15+
npm start
16+
fi
17+
18+
# Keep the container running
19+
tail -f /dev/null

0 commit comments

Comments
 (0)