create-express-kickstart 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js CHANGED
@@ -71,6 +71,7 @@ async function init() {
71
71
  : 'npm';
72
72
 
73
73
  const initGit = (await question('\nšŸ‘‰ Initialize a git repository? [Y/n] ')).toLowerCase() !== 'n';
74
+ const initDocker = (await question('šŸ‘‰ Include Dockerfile & docker-compose.yml? [Y/n] ')).toLowerCase() !== 'n';
74
75
 
75
76
  rl.close();
76
77
 
@@ -111,6 +112,18 @@ async function init() {
111
112
  fs.copyFileSync(envExamplePath, path.join(projectPath, '.env'));
112
113
  }
113
114
 
115
+ if (initDocker) {
116
+ console.log(`🐳 Adding Docker files...`);
117
+ const dockerfilePath = path.join(__dirname, '..', 'templates', 'Dockerfile');
118
+ const dockerComposePath = path.join(__dirname, '..', 'templates', 'docker-compose.yml');
119
+
120
+ // Fallbacks if templates aren't bundled right
121
+ if (fs.existsSync(dockerfilePath)) fs.copyFileSync(dockerfilePath, path.join(projectPath, 'Dockerfile'));
122
+ if (fs.existsSync(dockerComposePath) && deps.mongoose) {
123
+ fs.copyFileSync(dockerComposePath, path.join(projectPath, 'docker-compose.yml'));
124
+ }
125
+ }
126
+
114
127
  // 3. Create package.json
115
128
  console.log(`šŸ“¦ Setting up package.json...`);
116
129
  const packageJsonTemplate = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-express-kickstart",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Production-ready CLI starter for Express APIs",
5
5
  "main": "bin/cli.js",
6
6
  "bin": {
@@ -0,0 +1,20 @@
1
+ # Use official Node.js runtime as a parent image
2
+ FROM node:20-alpine
3
+
4
+ # Set working directory inside the container
5
+ WORKDIR /usr/src/app
6
+
7
+ # Copy package.json and lockfile based on package manager used
8
+ COPY package.json ./
9
+
10
+ # Install project dependencies
11
+ RUN npm install --production
12
+
13
+ # Bundle app source
14
+ COPY . .
15
+
16
+ # Expose port the app runs on
17
+ EXPOSE 3000
18
+
19
+ # Command to run your app
20
+ CMD [ "node", "src/server.js" ]
@@ -0,0 +1,26 @@
1
+ version: '3.8'
2
+
3
+ services:
4
+ app:
5
+ build: .
6
+ ports:
7
+ - "3000:3000"
8
+ environment:
9
+ - NODE_ENV=development
10
+ - PORT=3000
11
+ - MONGO_URI=mongodb://mongo:27017/express-api
12
+ volumes:
13
+ - .:/usr/src/app
14
+ - /usr/src/app/node_modules
15
+ depends_on:
16
+ - mongo
17
+
18
+ mongo:
19
+ image: mongo:latest
20
+ ports:
21
+ - "27017:27017"
22
+ volumes:
23
+ - mongo-data:/data/db
24
+
25
+ volumes:
26
+ mongo-data: