feat(ci): stabilize infrastructure and deployment pipeline

This commit is contained in:
2026-01-12 18:41:32 +01:00
parent f6b3931177
commit f819c6d708
7 changed files with 95 additions and 2 deletions

1
.env.dist Normal file
View File

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

9
Caddyfile Normal file
View File

@@ -0,0 +1,9 @@
:80 {
root * /usr/share/caddy
file_server
# Client cache
header {
Cache-Control "public, max-age=86400"
}
}

24
Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
ARG CADDY_VERSION
# --- BUILD ---
FROM node:24-alpine AS build
RUN corepack enable && corepack prepare pnpm@latest --activate
ENV ASTRO_TELEMETRY_DISABLED=1
WORKDIR /app
# Copy depedencies
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# Copy all and build
COPY . .
RUN pnpm build
# --- DEPLOY ---
FROM caddy:${CADDY_VERSION}-alpine
COPY --from=build /app/dist /usr/share/caddy
COPY Caddyfile /etc/caddy/Caddyfile
EXPOSE 80

44
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,44 @@
pipeline {
agent any
environment {
DOCKER_HOST = "unix:///var/run/docker.sock"
}
stages {
stage('Build') {
steps {
// 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') {
// Deploy only master branch
when {
branch 'master'
}
steps {
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"
}
}
}
post {
always {
echo "Clean unused image..."
sh "docker image prune -f"
}
success { echo "Success !" }
failure { echo "Failed." }
}
}

15
docker-compose.yml Normal file
View File

@@ -0,0 +1,15 @@
services:
portfolio:
build:
context: .
args:
- CADDY_VERSION=${CADDY_VERSION}
image: portfolio:${PORTFOLIO_VERSION}
container_name: portfolio
restart: always
networks:
- reverse-proxy
networks:
reverse-proxy:
external: true

View File

@@ -3,7 +3,7 @@ const today = new Date();
---
<footer>
&copy; {today.getFullYear()} Your name here. All rights reserved.
&copy; {today.getFullYear()} Lucas Royer. All rights reserved.
<div class="social-links">
<a href="https://m.webtoo.ls/@astro" target="_blank">
<span class="sr-only">Follow Astro on Mastodon</span>

View File

@@ -13,7 +13,7 @@ import { SITE_DESCRIPTION, SITE_TITLE } from '../consts';
<body>
<Header />
<main>
<h1>🧑‍🚀 Hello, Astronaut!</h1>
<h1>🧑‍🚀 Welcome, there !</h1>
<p>
Welcome to the official <a href="https://astro.build/">Astro</a> blog starter template. This template
serves as a lightweight, minimally-styled starting point for anyone looking to build a personal