Initial commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
||||
71
README.md
Normal file
71
README.md
Normal file
@ -0,0 +1,71 @@
|
||||
# NodeJS Project
|
||||
This is a template project for NodeJS projects.
|
||||
|
||||
## Setup
|
||||
- Clone the repository: `git clone <repo_url>`
|
||||
- Copy `example.env` to `.env`
|
||||
- Configure `.env`
|
||||
- You're done
|
||||
|
||||
## Start
|
||||
- Run `docker compose up -d`
|
||||
- Check if everything is working
|
||||
- You're done
|
||||
|
||||
## Run commands in container
|
||||
|
||||
### If the container is running
|
||||
```sh
|
||||
docker compose exec nodejs <your_command>
|
||||
```
|
||||
|
||||
### If the container is not running
|
||||
```sh
|
||||
docker compose run --rm nodejs <your_command>
|
||||
```
|
||||
|
||||
## Other commands
|
||||
|
||||
### Rebuild container
|
||||
```sh
|
||||
docker compose build
|
||||
```
|
||||
|
||||
### Init git submodules (if any)
|
||||
```sh
|
||||
git submodule update --init --recursive
|
||||
```
|
||||
|
||||
### Update git submodule
|
||||
```sh
|
||||
# Enter the submodule directory
|
||||
cd <submodule_folder>
|
||||
# Pull the other repo
|
||||
git pull
|
||||
# Go back to the root directory of the project
|
||||
cd ..
|
||||
# Check update
|
||||
git status
|
||||
# Commit update
|
||||
git add <submodule_folder>
|
||||
git commit -m "Submodule updated"
|
||||
```
|
||||
|
||||
### Update git submodule (other method)
|
||||
```sh
|
||||
git submodule update --remote --merge
|
||||
```
|
||||
|
||||
### Add git submodule
|
||||
```sh
|
||||
git submodule add <url>
|
||||
# or
|
||||
git submodule add <url> <path>
|
||||
```
|
||||
|
||||
### Remove git submodule
|
||||
```sh
|
||||
git submodule deinit -f <path>
|
||||
git rm -f <path>
|
||||
rm -rf .git/modules/<path>
|
||||
```
|
||||
131
app/.gitignore
vendored
Normal file
131
app/.gitignore
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
# ---> Node
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
5
app/index.js
Normal file
5
app/index.js
Normal file
@ -0,0 +1,5 @@
|
||||
let i = 0;
|
||||
setInterval(() => {
|
||||
i++;
|
||||
console.log(`Hello, World! (#${i})`);
|
||||
}, 1000);
|
||||
13
app/package-lock.json
generated
Normal file
13
app/package-lock.json
generated
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "app",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "app",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC"
|
||||
}
|
||||
}
|
||||
}
|
||||
12
app/package.json
Normal file
12
app/package.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "app",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": ""
|
||||
}
|
||||
2
data/.gitignore
vendored
Normal file
2
data/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/*
|
||||
!.gitignore
|
||||
17
docker-compose.yml
Normal file
17
docker-compose.yml
Normal file
@ -0,0 +1,17 @@
|
||||
services:
|
||||
nodejs:
|
||||
image: node:22-alpine
|
||||
working_dir: /usr/project/app
|
||||
restart: unless-stopped
|
||||
command: >
|
||||
sh -c 'echo "Running setup...";
|
||||
npm install;
|
||||
echo "Starting the node...";
|
||||
npm start'
|
||||
volumes:
|
||||
- ./app/:/usr/project/app/:rw
|
||||
- ./.env:/usr/project/.env:ro
|
||||
- ./example.env:/usr/project/example.env:ro
|
||||
- ./data/:/usr/project/data/:rw
|
||||
ports:
|
||||
- "${PORT}:${PORT}"
|
||||
2
example.env
Normal file
2
example.env
Normal file
@ -0,0 +1,2 @@
|
||||
# Server listening port
|
||||
PORT=8080
|
||||
Reference in New Issue
Block a user