Skip to content

Commit

Permalink
Merge pull request #499 from sharafdin/feature/support-docker
Browse files Browse the repository at this point in the history
Docker support for all templates
  • Loading branch information
sharafdin authored Aug 15, 2024
2 parents 3c207c6 + ade777a commit e00c4a6
Show file tree
Hide file tree
Showing 79 changed files with 1,053 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ SERVER_PORT=
# Database Configuration
# ----------------------
# Provide the URL for connecting to the database. This should include the protocol, username, password, and host as applicable.
# For example, 'mongodb://root:example@localhost:27017/'.
# If you are using docker-compose, the database URL should be 'mongodb://root:toor@db:27017/' where 'db' is the name of the database service.
DATABASE_URL=


# Specify the name of the database to which the application will connect.
# If not specified, the default database 'yonodeDB' will be used.
# Default: yonodeDB
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:21

EXPOSE 8000

WORKDIR /app

COPY . .

RUN npm install -g pnpm

RUN npm install -g nodemon

RUN pnpm install

CMD ["nodemon", "-L", "./src/app.js"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.9'

services:
db:
image: mongo:latest
container_name: mongo-db
ports:
- '27017:27017'
restart: on-failure
# healthcheck:
# test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
# interval: 10s
# timeout: 5s
# retries: 5


server:
build: .
container_name: yonode-server
restart: on-failure
volumes:
- .:/app
- /app/node_modules
ports:
- '8000:8000'
environment:
DATABASE_URL: ${DATABASE_URL}
SERVER_PORT: ${SERVER_PORT}
JWT_SECRET_KEY: ${JWT_SECRET_KEY}
NODE_ENVIRONMENT: ${NODE_ENVIRONMENT}
depends_on:
- db

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ SERVER_PORT=
# Database Configuration
# ----------------------
# Provide the URL for connecting to the database. This should include the protocol, username, password, and host as applicable.
# For example, 'mongodb://root:example@localhost:27017/'.
# If you are using docker-compose, the database URL should be 'mongodb://root:toor@db:27017/' where 'db' is the name of the database service.
DATABASE_URL=


# Specify the name of the database to which the application will connect.
# If not specified, the default database 'yonodeDB' will be used.
# Default: yonodeDB
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:21

EXPOSE 8000

WORKDIR /app

COPY . .

RUN npm install -g pnpm

RUN npm install -g nodemon

RUN pnpm install

CMD ["nodemon", "-L", "./src/app.js"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.9'

services:
db:
image: mongo:latest
container_name: mongo-db
ports:
- '27017:27017'
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: toor
restart: on-failure
# healthcheck:
# test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
# interval: 10s
# timeout: 5s
# retries: 5


server:
build: .
container_name: yonode-server
restart: on-failure
volumes:
- .:/app
- /app/node_modules
ports:
- '8000:8000'
environment:
DATABASE_URL: ${DATABASE_URL}
SERVER_PORT: ${SERVER_PORT}
JWT_SECRET_KEY: ${JWT_SECRET_KEY}
NODE_ENVIRONMENT: ${NODE_ENVIRONMENT}
depends_on:
- db

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ SERVER_PORT=
# Database Configuration
# ----------------------
# Provide the URL for connecting to the database. This should include the protocol, username, password, and host as applicable.
# For example, 'mongodb://root:example@localhost:27017/yonodeDB'.
# If you are using docker-compose, the database URL should be 'mongodb://root:toor@db:27017/yonodeDB' where 'db' is the name of the database service.
DATABASE_URL=

# Authentication and Security Configuration
Expand All @@ -22,4 +24,4 @@ JWT_SECRET_KEY=
# This setting can influence the application's behavior, enabling or disabling certain features based on the environment.
# For example, in 'development' mode, more verbose logging might be enabled, whereas 'production' might focus on performance optimizations and error handling.
# Default: development (if not specified)
NODE_ENVIRONMENT=
NODE_ENVIRONMENT=
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:21

EXPOSE 8000

WORKDIR /app

COPY . .

RUN npm install -g pnpm

RUN npm install -g nodemon

RUN pnpm install

RUN npx prisma generate

CMD ["nodemon", "-L", "./src/app.js"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.9'

services:
db:
image: mongo:latest
container_name: mongo-db
ports:
- '27017:27017'
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: toor
restart: on-failure
# healthcheck:
# test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
# interval: 10s
# timeout: 5s
# retries: 5


server:
build: .
container_name: yonode-server
restart: on-failure
volumes:
- .:/app
- /app/node_modules
ports:
- '8000:8000'
environment:
DATABASE_URL: ${DATABASE_URL}
SERVER_PORT: ${SERVER_PORT}
JWT_SECRET_KEY: ${JWT_SECRET_KEY}
NODE_ENVIRONMENT: ${NODE_ENVIRONMENT}
depends_on:
- db

Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"helmet": "^7.1.0",
"jsonwebtoken": "^9.0.2",
"mongoose": "^8.3.4",
"morgan": "^1.10.0"
"morgan": "^1.10.0",
"prisma": "^5.13.0"
},
"devDependencies": {
"nodemon": "^3.1.0",
"yonode": "^1.2.3",
"prisma": "^5.13.0"
"yonode": "^1.2.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ SERVER_PORT=

# Database Configuration
# ----------------------
# Provide the URL for connecting to the database, This should include the protocol, username, password, host, port, and database name as applicable.
# Format: protocol://username:password@host:port/databaseName
# Provide the URL for connecting to the database. This should include the protocol, username, password, and host as applicable.
# For example, 'mongodb://root:example@localhost:27017/yonodeDB'.
# If you are using docker-compose, the database URL should be 'mongodb://root:toor@db:27017/yonodeDB' where 'db' is the name of the database service.
DATABASE_URL=

# Authentication and Security Configuration
Expand All @@ -23,4 +24,4 @@ JWT_SECRET_KEY=
# This setting can influence the application's behavior, enabling or disabling certain features based on the environment.
# For example, in 'development' mode, more verbose logging might be enabled, whereas 'production' might focus on performance optimizations and error handling.
# Default: development (if not specified)
NODE_ENVIRONMENT=
NODE_ENVIRONMENT=
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:21

EXPOSE 8000

WORKDIR /app

COPY . .

RUN npm install -g pnpm

RUN npm install -g nodemon

RUN pnpm install

RUN npx prisma generate

CMD ["nodemon", "-L", "./src/app.js"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.9'

services:
db:
image: mongo:latest
container_name: mongo-db
ports:
- '27017:27017'
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: toor
restart: on-failure
# healthcheck:
# test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
# interval: 10s
# timeout: 5s
# retries: 5


server:
build: .
container_name: yonode-server
restart: on-failure
volumes:
- .:/app
- /app/node_modules
ports:
- '8000:8000'
environment:
DATABASE_URL: ${DATABASE_URL}
SERVER_PORT: ${SERVER_PORT}
JWT_SECRET_KEY: ${JWT_SECRET_KEY}
NODE_ENVIRONMENT: ${NODE_ENVIRONMENT}
depends_on:
- db

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ SERVER_PORT=
# Database Configuration
# ----------------------
# Provide the URL for connecting to the database. This should include the protocol, username, password, and host as applicable.
# For example, 'mongodb://root:example@localhost:27017/'.
# If you are using docker-compose, the database URL should be 'mongodb://root:toor@db:27017/' where 'db' is the name of the database service.
DATABASE_URL=


# Specify the name of the database to which the application will connect.
# If not specified, the default database 'yonodeDB' will be used.
# Default: yonodeDB
Expand All @@ -27,4 +30,4 @@ JWT_SECRET_KEY=
# This setting can influence the application's behavior, enabling or disabling certain features based on the environment.
# For example, in 'development' mode, more verbose logging might be enabled, whereas 'production' might focus on performance optimizations and error handling.
# Default: development (if not specified)
NODE_ENVIRONMENT=
NODE_ENVIRONMENT=
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:21

EXPOSE 8000

WORKDIR /app

COPY . .

RUN npm install -g pnpm

RUN npm install -g nodemon

RUN pnpm install

CMD ["nodemon", "-L", "./src/app.js"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3.9'

services:
db:
image: mongo:latest
container_name: mongo-db
ports:
- '27017:27017'
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: toor
restart: on-failure
# healthcheck:
# test: echo 'db.stats().ok' | mongo localhost:27017/test --quiet
# interval: 10s
# timeout: 5s
# retries: 5


server:
build: .
container_name: yonode-server
restart: on-failure
volumes:
- .:/app
- /app/node_modules
ports:
- '8000:8000'
environment:
DATABASE_URL: ${DATABASE_URL}
SERVER_PORT: ${SERVER_PORT}
JWT_SECRET_KEY: ${JWT_SECRET_KEY}
NODE_ENVIRONMENT: ${NODE_ENVIRONMENT}
depends_on:
- db

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const AppDataSource = new DataSource({
database: dbName,
entities: [User],
synchronize: true,
authSource: "admin"
});

AppDataSource.initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ SERVER_PORT=
# Database Configuration
# ----------------------
# Provide the URL for connecting to the database. This should include the protocol, username, password, and host as applicable.
# For example, 'mongodb://root:example@localhost:27017/'.
# If you are using docker-compose, the database URL should be 'mongodb://root:toor@db:27017/' where 'db' is the name of the database service.
DATABASE_URL=


# Specify the name of the database to which the application will connect.
# If not specified, the default database 'yonodeDB' will be used.
# Default: yonodeDB
Expand Down
Loading

0 comments on commit e00c4a6

Please sign in to comment.