Docker & Jenkins

master
Araozu 2024-02-29 09:14:57 -05:00
parent 28d20f7aca
commit f54cf63662
4 changed files with 57 additions and 22 deletions

15
.dockerignore Normal file
View File

@ -0,0 +1,15 @@
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*

14
Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM oven/bun:latest as base
WORKDIR /usr/src/app
# Copy the dist folder from here
COPY . .
ENV NODE_ENV=production
# Install deps
RUN bun install --frozen-lockfile --production
# run the app
USER bun
EXPOSE 3485/tcp
ENTRYPOINT [ "bun", "run", "srv/index.ts" ]

25
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,25 @@
pipeline {
agent any
environment {
PATH = "/var/lib/jenkins/.nvm/versions/node/v20.9.0/bin:/var/lib/jenkins/bin:${env.PATH}"
}
stages {
stage('Install') {
steps {
sh 'pnpm i'
}
}
stage('Build frontend') {
steps {
sh 'pnpm build-only'
}
}
stage('Deploy') {
steps {
sh 'docker build -t bun-pseudosubs-v1:latest .'
sh 'docker stop bun-pseudosubs-v1 && docker rm bun-pseudosubs-v1'
sh 'docker run -d --name bun-pseudosubs-v1 -p 3485:3485 bun-pseudosubs-v1:latest'
}
}
}
}

View File

@ -20,14 +20,15 @@ import {estadisticas} from './Admin/Eps/estadisticas';
console.log("express??");
const app = express();
const port = 3000;
const port = 3485;
const expressApp = (app: core.Express) => {
app.use(express.json());
app.use(express.urlencoded());
app.get("/");
// Serve the frontend
app.use(express.static("dist"));
app.post('/links', require('./LinksAnimes/obtenerLinks').obtenerLinks);
app.put('/links', require('./LinksAnimes/modificarLink').modificarLink);
@ -65,26 +66,6 @@ export const sqliteConnection = {
},
};
const conexion = (() => {
const con = mysql.createConnection({
host: 'localhost',
user: 'root',
password: '123456789',
database: 'pseudo',
});
con.connect((err) => {
if (!err) {
console.log("MySQL iniciado c:");
} else {
throw err;
}
});
return con;
})();
expressApp(app);
app.listen(port, () => {