Add caddy version control, explicit portfolio version, cache management
All checks were successful
Portfolio/pipeline/head This commit looks good

This commit is contained in:
2026-01-08 19:39:17 +01:00
parent b4c10b62cc
commit 3f98cac537
5 changed files with 22 additions and 9 deletions

1
.env.dist Normal file
View File

@@ -0,0 +1 @@
CADDY_VERSION=2.10.2

View File

@@ -2,10 +2,8 @@
root * /usr/share/caddy
file_server
# No cache, always update
# Client cache
header {
Cache-Control "no-cache, no-store, must-revalidate"
Pragma "no-cache"
Expires "0"
Cache-Control "public, max-age=86400"
}
}

View File

@@ -1,3 +1,5 @@
ARG CADDY_VERSION
# --- BUILD ---
FROM node:24-alpine AS build
RUN corepack enable && corepack prepare pnpm@latest --activate
@@ -15,7 +17,7 @@ COPY . .
RUN pnpm build
# --- DEPLOY ---
FROM caddy:alpine
FROM caddy:${CADDY_VERSION}-alpine
COPY --from=build /app/dist /usr/share/caddy
COPY Caddyfile /etc/caddy/Caddyfile

14
Jenkinsfile vendored
View File

@@ -4,10 +4,15 @@ pipeline {
DOCKER_HOST = "unix:///var/run/docker.sock"
}
stages {
stage('Docker Build') {
stage('Build') {
steps {
echo "Build new docker image from ${env.BRANCH_NAME}..."
sh "docker build -t portfolio:${env.BRANCH_NAME} ."
// Get Caddy version
sh "cp .env.dist .env"
// Push portfolio version
sh "echo '\nPORTFOLIO_VERSION=${env.BRANCH_NAME}-${env.BUILD_NUMBER}' >> .env"
echo "Building new portfolio version..."
sh "docker compose build"
}
}
stage('Deploy') {
@@ -19,6 +24,9 @@ pipeline {
echo "Deploy new portfolio version..."
sh "docker compose up -d"
// Update caddy-reverse-proxy cache
sh "docker exec caddy-reverse-proxy caddy reload --config /etc/caddy/Caddyfile"
// Keep updated docker-compose.yml and Caddyfile for safety
sh "cp docker-compose.yml /backup-portfolio/docker-compose.yml"
sh "docker cp portfolio:/etc/caddy/Caddyfile /backup-portfolio/Caddyfile"

View File

@@ -1,6 +1,10 @@
services:
portfolio:
image: portfolio:master
build:
context: .
args:
- CADDY_VERSION=${CADDY_VERSION}
image: portfolio:${PORTFOLIO_VERSION}
container_name: portfolio
restart: always
networks: