first commit
This commit is contained in:
commit
c56aafd75b
6 changed files with 261 additions and 0 deletions
174
.gitignore
vendored
Normal file
174
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
||||
|
||||
# Logs
|
||||
|
||||
logs
|
||||
_.log
|
||||
npm-debug.log_
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Caches
|
||||
|
||||
.cache
|
||||
|
||||
# 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/)
|
||||
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
|
||||
.nuxt
|
||||
|
||||
# Gatsby files
|
||||
|
||||
# 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
|
||||
|
||||
# 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.*
|
||||
|
||||
# IntelliJ based IDEs
|
||||
.idea
|
||||
|
||||
# Finder (MacOS) folder config
|
||||
.DS_Store
|
||||
29
Dockerfile
Normal file
29
Dockerfile
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# PREPARATION
|
||||
# Create temporary package.json where version is set to "0.0.0"
|
||||
# This way the cache of the build step won't be invalidated if only the version changed.
|
||||
FROM node:lts-alpine AS preparation
|
||||
COPY package.json service/create-tmp-pkg.js ./
|
||||
RUN node create-tmp-pkg.js
|
||||
|
||||
# BUILD
|
||||
# Usa la imagen oficial de Node.js como base
|
||||
FROM node:22-alpine AS build
|
||||
|
||||
# Establece el directorio de trabajo dentro del contenedor
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copia e instala las dependencias
|
||||
COPY --from=preparation package*.json ./
|
||||
RUN yarn install
|
||||
|
||||
# Copia el resto del código fuente
|
||||
COPY . .
|
||||
|
||||
# Compila el código TypeScript a JavaScript
|
||||
# RUN npm run build
|
||||
|
||||
# Expone el puerto que la aplicación usa
|
||||
EXPOSE 3000
|
||||
|
||||
# Define el comando para ejecutar la aplicación
|
||||
CMD ["node", "dist/server.js"]
|
||||
13
dist/server.js
vendored
Normal file
13
dist/server.js
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import express from 'express';
|
||||
|
||||
const app = express();
|
||||
const PORT = parseInt(process.env.PORT ?? "3000");
|
||||
const HOST = process.env.HOST ?? '0.0.0.0';
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
console.log(`Request received: ${req.method} ${req.url}`);
|
||||
res.send('Hello, World!');
|
||||
});
|
||||
app.listen(PORT, HOST, () => {
|
||||
console.log(`Server is running at http://${HOST}:${PORT}`);
|
||||
});
|
||||
14
package.json
Normal file
14
package.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "docker_test",
|
||||
"type": "module",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"docker": "npm run dockerBuild && npm run dockerPush",
|
||||
"dockerBuild": "docker build -t codetest.wundersolutions.es/juanjo/test_repo:$npm_package_version .",
|
||||
"dockerPush": "docker push codetest.wundersolutions.es/juanjo/test_repo:$npm_package_version",
|
||||
"": ""
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^5.1.0"
|
||||
}
|
||||
}
|
||||
25
service/create-tmp-pkg.js
Normal file
25
service/create-tmp-pkg.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
|
||||
import { readFileSync, writeFileSync } from "fs";
|
||||
|
||||
try {
|
||||
const pkg = JSON.parse(readFileSync("package.json", "utf-8"));
|
||||
writeFileSync("package.json", JSON.stringify({
|
||||
dependencies: pkg.dependencies,
|
||||
devDependencies: pkg.devDependencies,
|
||||
}));
|
||||
} catch (e) {
|
||||
console.warn("Error al convertir package.json a JSON");
|
||||
}
|
||||
|
||||
try {
|
||||
const pkgLock = JSON.parse(readFileSync("package-lock.json", "utf-8"));
|
||||
writeFileSync("package-lock.json", JSON.stringify({
|
||||
lockfileVersion: pkgLock.lockfileVersion,
|
||||
requires: pkgLock.requires,
|
||||
packages: pkgLock.packages,
|
||||
}));
|
||||
} catch (e) {
|
||||
console.warn("Error al convertir package-lock.json a JSON");
|
||||
}
|
||||
6
service/docker-compose.yml
Normal file
6
service/docker-compose.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
services:
|
||||
api-mysql:
|
||||
image: code.wundersolutions.es/domusa/ic_apirest:2.0.0
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 9002:3000
|
||||
Loading…
Reference in a new issue