Skip to content

Commit 8143b41

Browse files
feat(docker): rename dockerignore during init and add docs guide
1 parent 7ba29d6 commit 8143b41

File tree

5 files changed

+82
-1
lines changed

5 files changed

+82
-1
lines changed

lib/commands/init.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ function printSuccessMessage(projectName, packageManager) {
144144
console.log(chalk.white(` ${INIT.DOC_AUTH}`));
145145
console.log(chalk.white(` ${INIT.DOC_SERVICES}`));
146146
console.log(chalk.white(` ${INIT.DOC_CLI}`));
147+
console.log(chalk.white(` ${INIT.DOC_DOCKER}`));
147148

148149
// ── CLI quick reference ────────────────────────────────
149150
console.log("\n");

lib/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const INIT = {
4444
DOC_AUTH: "docs/authentication.md Auth and OTP endpoints",
4545
DOC_SERVICES: "docs/services.md Email, S3, Cloudinary usage",
4646
DOC_CLI: "docs/cli-usage.md CLI commands and patterns",
47+
DOC_DOCKER: "docs/docker.md Docker orchestration and setup",
4748
SECTION_COMMANDS: "Commands",
4849
CMD_MODULE: "tas add-module <Name> Full module (controller + model + router)",
4950
CMD_ROUTER: "tas add-router <Name> Express router",

lib/core/projectCreator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const chalk = require("chalk");
44
const ora = require("ora");
55
const { execSync } = require("child_process");
66

7-
const PSEUDO_DOTFILES = ["_gitignore", "_babelrc"];
7+
const PSEUDO_DOTFILES = ["_gitignore", "_babelrc", "_dockerignore"];
88
const ENV_FILENAME = "config.env";
99

1010
/**
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
npm-debug.log
3+
.env
4+
.env.*
5+
config.env
6+
.git
7+
.gitignore
8+
coverage
9+
Src/Uploads/Logs
10+
*.md
11+
docker-compose.yml
12+
.dockerignore
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Docker Setup & Commands
2+
3+
This application is fully containerized for both development and production. By using Docker, you eliminate "it works on my machine" issues and get a consistent environment instantly.
4+
5+
## Architecture
6+
7+
The `docker-compose.yml` spins up two services:
8+
1. **app:** The Node.js application container
9+
2. **mongo:** A designated MongoDB container with persistent data volumes
10+
11+
## Prerequisites
12+
13+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed and running.
14+
15+
---
16+
17+
## 🔥 Quick Start (Local Orchestration)
18+
19+
To spin up the entire application (Node.js API + MongoDB) in one command:
20+
21+
```bash
22+
docker-compose up -d
23+
```
24+
25+
> **Note:** The `-d` flag runs the containers in detached mode (in the background).
26+
27+
### Stopping the Containers
28+
To stop the application and database gracefully:
29+
```bash
30+
docker-compose down
31+
```
32+
33+
---
34+
35+
## 🛠️ Handy Docker Commands
36+
37+
### 1. View Application Logs
38+
If you ran `docker-compose up -d` and want to see your server logs (e.g. to see startup errors or API requests):
39+
```bash
40+
docker-compose logs -f app
41+
```
42+
43+
### 2. Rebuild the Application Container
44+
If you added a new NPM package or changed the `Dockerfile`, you must rebuild the image:
45+
```bash
46+
docker-compose up -d --build
47+
```
48+
49+
### 3. Clear Database Volumes (Reset Data)
50+
To stop the application AND permanently delete all data in the MongoDB volume (Useful for a fresh slate):
51+
```bash
52+
docker-compose down -v
53+
```
54+
55+
---
56+
57+
## 📦 Production Deployment
58+
59+
If you are deploying to a production server (like AWS EC2, DigitalOcean, or Render), you only need to build the API image.
60+
61+
```bash
62+
# 1. Build the production Docker image
63+
docker build -t tryappstack-api .
64+
65+
# 2. Run the container (Make sure to pass your custom ENV file)
66+
docker run -d -p 3000:3000 --env-file config.env tryappstack-api
67+
```

0 commit comments

Comments
 (0)