Add Jenkinsfile for deployment and update docker-compose

This commit is contained in:
Francesco Albano 2025-11-27 11:51:02 +08:00
parent 674f035ae4
commit d7996c0601
10 changed files with 99 additions and 6 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

80
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,80 @@
pipeline {
agent any
environment {
DEPLOY_SERVER = '192.168.1.161'
DEPLOY_USER = 'root'
DEPLOY_PASS = 'Temp1234!'
DEPLOY_PATH = '/opt/trip'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build Docker Image') {
steps {
script {
sh 'docker build -t trip:${BUILD_NUMBER} .'
sh 'docker tag trip:${BUILD_NUMBER} trip:latest'
}
}
}
stage('Save Docker Image') {
steps {
script {
sh 'docker save trip:latest > trip.tar'
}
}
}
stage('Deploy') {
steps {
script {
if (env.BRANCH_NAME != 'main') {
echo "Skipping deployment: not on main branch"
return
}
echo "Deploying to PRODUCTION VM: ${DEPLOY_SERVER}"
sh """
# Installa sshpass se non presente
which sshpass || (apt-get update && apt-get install -y sshpass)
sshpass -p '${DEPLOY_PASS}' scp -o StrictHostKeyChecking=no trip.tar ${DEPLOY_USER}@${DEPLOY_SERVER}:${DEPLOY_PATH}/
sshpass -p '${DEPLOY_PASS}' scp -o StrictHostKeyChecking=no docker-compose.yml ${DEPLOY_USER}@${DEPLOY_SERVER}:${DEPLOY_PATH}/
# Copia storage solo al primo deploy, poi commenta questa riga
sshpass -p '${DEPLOY_PASS}' scp -o StrictHostKeyChecking=no -r storage ${DEPLOY_USER}@${DEPLOY_SERVER}:${DEPLOY_PATH}/ 2>/dev/null || true
sshpass -p '${DEPLOY_PASS}' ssh -o StrictHostKeyChecking=no ${DEPLOY_USER}@${DEPLOY_SERVER} "
cd ${DEPLOY_PATH}
docker load < trip.tar
docker-compose down || true
docker-compose up -d
rm trip.tar
"
"""
echo "Deployment completed to ${DEPLOY_SERVER}"
}
}
}
}
post {
success {
echo 'Deployment successful!'
}
failure {
echo 'Deployment failed!'
}
always {
cleanWs()
}
}
}

Binary file not shown.

View File

@ -1,6 +1,6 @@
services:
app:
image: ghcr.io/itskovacs/trip:1
build: .
ports:
- 127.0.0.1:8080:8000 #127.0.0.1: locally exposed, on port 8080 by default
volumes:

View File

@ -20,7 +20,9 @@
"outputPath": "dist/trip",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
@ -63,6 +65,9 @@
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"proxyConfig": "proxy.conf.json"
},
"configurations": {
"production": {
"buildTarget": "trip:build:production"
@ -79,7 +84,10 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
@ -88,7 +96,9 @@
"input": "public"
}
],
"styles": ["src/styles.scss"],
"styles": [
"src/styles.scss"
],
"scripts": []
}
}
@ -98,4 +108,4 @@
"cli": {
"analytics": false
}
}
}

View File

@ -586,7 +586,7 @@
</div>
}
</div>
<!--
<div class="p-4 shadow rounded-md w-full min-h-20">
<div class="p-2 mb-2 flex justify-between items-center">
<h1 class="font-semibold tracking-tight text-xl">About</h1>
@ -605,6 +605,7 @@
coffee</a>
</div>
</div>
-->
}
</div>
</section>

View File

@ -27,6 +27,7 @@ import { calculateDistanceBetween } from '../../shared/haversine';
import { orderByPipe } from '../../shared/order-by.pipe';
import { generateTripICSFile } from '../trip/ics';
import { generateTripCSVFile } from '../trip/csv';
import { DatePicker } from "primeng/datepicker";
@Component({
selector: 'app-shared-trip',
@ -48,6 +49,7 @@ import { generateTripCSVFile } from '../trip/csv';
CheckboxModule,
ClipboardModule,
orderByPipe,
DatePicker
],
templateUrl: './shared-trip.component.html',
styleUrls: ['./shared-trip.component.scss'],

Binary file not shown.