commit 76e30eebb2c123118b6349fc70fab63bc72802fb Author: Cyanoure Date: Sun Sep 15 10:58:45 2024 +0000 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/README.md b/README.md new file mode 100644 index 0000000..d640fe9 --- /dev/null +++ b/README.md @@ -0,0 +1,71 @@ +# NodeJS Project +This is a template project for NodeJS projects. + +## Setup +- Clone the repository: `git clone ` +- 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 +``` + +### If the container is not running +```sh +docker compose run --rm nodejs +``` + +## 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 +# Pull the other repo +git pull +# Go back to the root directory of the project +cd .. +# Check update +git status +# Commit update +git add +git commit -m "Submodule updated" +``` + +### Update git submodule (other method) +```sh +git submodule update --remote --merge +``` + +### Add git submodule +```sh +git submodule add +# or +git submodule add +``` + +### Remove git submodule +```sh +git submodule deinit -f +git rm -f +rm -rf .git/modules/ +``` diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..745264f --- /dev/null +++ b/app/.gitignore @@ -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.* diff --git a/app/index.js b/app/index.js new file mode 100644 index 0000000..94cfad7 --- /dev/null +++ b/app/index.js @@ -0,0 +1,5 @@ +let i = 0; +setInterval(() => { + i++; + console.log(`Hello, World! (#${i})`); +}, 1000); diff --git a/app/package-lock.json b/app/package-lock.json new file mode 100644 index 0000000..9533877 --- /dev/null +++ b/app/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "app", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "app", + "version": "1.0.0", + "license": "ISC" + } + } +} diff --git a/app/package.json b/app/package.json new file mode 100644 index 0000000..3b01f05 --- /dev/null +++ b/app/package.json @@ -0,0 +1,12 @@ +{ + "name": "app", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "start": "node index.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "" +} diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..78d9101 --- /dev/null +++ b/data/.gitignore @@ -0,0 +1,2 @@ +/* +!.gitignore diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c86b9a1 --- /dev/null +++ b/docker-compose.yml @@ -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}" diff --git a/example.env b/example.env new file mode 100644 index 0000000..3f44963 --- /dev/null +++ b/example.env @@ -0,0 +1,2 @@ +# Server listening port +PORT=8080