Compare commits

...

15 Commits

Author SHA1 Message Date
df209edb27 fix(jenkins): new docker host rootless
All checks were successful
Portfolio/pipeline/head This commit looks good
2026-01-27 18:38:43 +01:00
f1794abe7e fix(jenkins): fix lighthouse audit launch in jenkinsfile
All checks were successful
Portfolio/pipeline/head This commit looks good
2026-01-12 19:03:20 +01:00
351256483f refactor(lighthouse): lighthouse local use same docker compose as jenkins 2026-01-12 19:03:20 +01:00
db7e655d4f perf(docker): add npm cache 2026-01-12 19:03:20 +01:00
952c75127a fix(lighthouse): change audit export path and config 2026-01-12 19:03:20 +01:00
fa8e84514a fix(lighthouse): switch to docker volumes 2026-01-12 19:01:53 +01:00
473bd7b05d fix(lighthouse): add mandatory publishHTML setting 2026-01-12 18:35:39 +01:00
31df2769a3 ci(lighthouse): add jenkins lighthouse automated audit 2026-01-12 18:35:39 +01:00
c01a5e2ef5 ci(lighthouse): add local lighthouse audit 2026-01-12 18:35:39 +01:00
ac96a7ce44 chore(git): ignore .vscode folder 2026-01-12 18:35:39 +01:00
64ca235045 chore(git): install husky and commitlint 2026-01-12 18:35:39 +01:00
81737767ee fix(check): missing dependance 2026-01-12 18:35:12 +01:00
02a0d694a1 fix(eslintrc): switch to new config name after update 2026-01-12 18:34:17 +01:00
8ede8ea80b feat(jenkins): deploy lint and check in dockerfile 2026-01-12 18:33:39 +01:00
00e6ba3454 feat(jenkins): manage node version 2026-01-12 18:32:45 +01:00
17 changed files with 2310 additions and 35 deletions

View File

@@ -1 +1,4 @@
CADDY_VERSION=2.10.2 NODE_VERSION=24
CADDY_VERSION=2.10.2
LHCI_VERSION=0.15.x
ZENIKA_VERSION=124-with-node

7
.gitignore vendored
View File

@@ -5,6 +5,7 @@ dist/
# dependencies # dependencies
node_modules/ node_modules/
.pnpm-store/
# logs # logs
npm-debug.log* npm-debug.log*
@@ -22,3 +23,9 @@ pnpm-debug.log*
# jetbrains setting folder # jetbrains setting folder
.idea/ .idea/
# vscode
.vscode/
# Lighthouse CI reports
.lighthouseci/

1
.husky/commit-msg Normal file
View File

@@ -0,0 +1 @@
pnpm exec commitlint --edit "$1"

2
.husky/pre-commit Normal file
View File

@@ -0,0 +1,2 @@
pnpm run lint
pnpm run check

24
.lighthouserc.cjs Normal file
View File

@@ -0,0 +1,24 @@
module.exports = {
ci: {
collect: {
staticDistDir: '/app/dist',
settings: {
chromeFlags: '--no-sandbox --disable-setuid-sandbox --headless=new --disable-gpu --disable-dev-shm-usage',
targets: ['filesystem'],
},
numberOfRuns: 1
},
assert: {
assertions: {
'categories:performance': ['error', {minScore: 0.9}],
'categories:accessibility': ['error', {minScore: 0.9}],
'categories:best-practices': ['error', {minScore: 0.9}],
'categories:seo': ['error', {minScore: 0.9}],
},
},
upload: {
target: 'filesystem',
outputDir: './.lighthouseci', // C'est ici que Jenkins ira chercher les fichiers
},
},
};

View File

@@ -1,4 +0,0 @@
{
"recommendations": ["astro-build.astro-vscode", "unifiedjs.vscode-mdx"],
"unwantedRecommendations": []
}

11
.vscode/launch.json vendored
View File

@@ -1,11 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}

View File

@@ -1,7 +1,8 @@
ARG NODE_VERSION
ARG CADDY_VERSION ARG CADDY_VERSION
# --- BUILD --- # --- BUILD ---
FROM node:24-alpine AS build FROM node:${NODE_VERSION}-alpine AS build
RUN corepack enable && corepack prepare pnpm@latest --activate RUN corepack enable && corepack prepare pnpm@latest --activate
ENV ASTRO_TELEMETRY_DISABLED=1 ENV ASTRO_TELEMETRY_DISABLED=1
@@ -10,10 +11,19 @@ WORKDIR /app
# Copy depedencies # Copy depedencies
COPY package.json pnpm-lock.yaml ./ COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# Copy all and build # Install pnpm with cache
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
PNPM_HOME="/pnpm" pnpm install --frozen-lockfile
# Copy all
COPY . . COPY . .
# Check files
RUN pnpm run lint
RUN pnpm run check
# Build
RUN pnpm build RUN pnpm build
# --- DEPLOY --- # --- DEPLOY ---

46
Jenkinsfile vendored
View File

@@ -1,7 +1,9 @@
pipeline { pipeline {
agent any agent any
environment { environment {
DOCKER_HOST = "unix:///var/run/docker.sock" DOCKER_HOST = "unix:///run/user/1001/docker.sock"
APP_VERSION = "${env.BRANCH_NAME}-${env.BUILD_NUMBER}"
DOCKER_CONFIG = "${env.WORKSPACE}/.docker"
} }
stages { stages {
stage('Build') { stage('Build') {
@@ -9,12 +11,41 @@ pipeline {
// Get Caddy version // Get Caddy version
sh "cp .env.dist .env" sh "cp .env.dist .env"
// Push portfolio version // Push portfolio version
sh "echo '\nPORTFOLIO_VERSION=${env.BRANCH_NAME}-${env.BUILD_NUMBER}' >> .env" sh "echo '\nPORTFOLIO_VERSION=${env.APP_VERSION}' >> .env"
echo "Building new portfolio version..." echo "Building new portfolio version..."
sh "docker compose build" sh "docker compose build"
} }
} }
stage('Lighthouse Audit') {
steps {
// Create volumes but no run with safety
sh "docker rm -f audit-tmp lighthouse-audit || true"
sh "docker compose --profile audit create --no-build --remove-orphans lighthouse-audit"
// Extract astro data from temp container to tmp-dist folder
sh "docker create --name audit-tmp portfolio:${env.APP_VERSION}"
sh "mkdir -p ./tmp-dist"
sh "docker cp audit-tmp:/usr/share/caddy/. ./tmp-dist"
sh "docker rm -f audit-tmp"
// Inject data from tmp-dist and config to audit container
sh "docker cp ./tmp-dist/. lighthouse-audit:/app/dist/"
sh "docker cp .lighthouserc.cjs lighthouse-audit:/app/dist/audit-config.cjs"
sh "rm -rf ./tmp-dist"
// Now run
sh "docker start -a lighthouse-audit"
// Get reports
sh "mkdir -p ./.lighthouseci"
sh "docker cp lighthouse-audit:/app/.lighthouseci/. ./.lighthouseci/"
// Clean
sh "docker rm -f lighthouse-audit"
}
}
stage('Deploy') { stage('Deploy') {
// Deploy only master branch // Deploy only master branch
when { when {
@@ -35,7 +66,16 @@ pipeline {
} }
post { post {
always { always {
echo "Clean unused image..." echo "Publish Lighthouse audit..."
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: false,
reportDir: '.lighthouseci',
reportFiles: '*.html',
reportName: 'Lighthouse Report'
])
echo "Clean unused image"
sh "docker image prune -f" sh "docker image prune -f"
} }
success { echo "Success !" } success { echo "Success !" }

1
commitlint.config.js Normal file
View File

@@ -0,0 +1 @@
export default { extends: ['@commitlint/config-conventional'] };

View File

@@ -3,6 +3,7 @@ services:
build: build:
context: . context: .
args: args:
- NODE_VERSION=${NODE_VERSION}
- CADDY_VERSION=${CADDY_VERSION} - CADDY_VERSION=${CADDY_VERSION}
image: portfolio:${PORTFOLIO_VERSION} image: portfolio:${PORTFOLIO_VERSION}
container_name: portfolio container_name: portfolio
@@ -10,6 +11,26 @@ services:
networks: networks:
- reverse-proxy - reverse-proxy
lighthouse-audit:
profiles:
- audit
image: zenika/alpine-chrome:${ZENIKA_VERSION}
container_name: lighthouse-audit
user: "0:0"
volumes:
- audit_dist:/app/dist
- audit_reports:/app/.lighthouseci
- npm_cache:/root/.npm
environment:
- CHROME_PATH=/usr/bin/chromium-browser
working_dir: /app
command: npx --prefer-offline @lhci/cli@${LHCI_VERSION} autorun --config=/app/dist/audit-config.cjs
volumes:
audit_dist:
audit_reports:
npm_cache:
networks: networks:
reverse-proxy: reverse-proxy:
external: true external: true

24
eslint.config.mjs Normal file
View File

@@ -0,0 +1,24 @@
import eslintPluginAstro from 'eslint-plugin-astro';
import tsParser from '@typescript-eslint/parser';
export default [
// Configuration pour les fichiers Astro
...eslintPluginAstro.configs.recommended,
{
files: ["**/*.astro"],
languageOptions: {
parser: eslintPluginAstro.parser,
parserOptions: {
parser: tsParser,
extraFileExtensions: [".astro"],
},
},
rules: {
// Tes règles personnalisées ici
},
},
// On ignore le dossier de build
{
ignores: ["dist/*", ".astro/*"]
}
];

28
local-lighthouse.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
# Clean old audits and containers
rm -rf ./.lighthouseci
docker rm -f lighthouse-audit || true
# Load env file and avoid warning for unused portofolio version
if [ -f .env.dist ]; then
export $(grep -v '^#' .env.dist | xargs)
fi
export PORTFOLIO_VERSION="local-audit"
# Create container but no start
docker compose --profile audit create --no-build --remove-orphans lighthouse-audit
# Inject data and config to container
docker cp ./dist/. lighthouse-audit:/app/dist/
docker cp .lighthouserc.cjs lighthouse-audit:/app/dist/audit-config.cjs
# Now run
docker start -a lighthouse-audit
# Get reports
mkdir -p ./.lighthouseci
docker cp lighthouse-audit:/app/.lighthouseci/. ./.lighthouseci/
# Clean container
docker rm -f lighthouse-audit

View File

@@ -6,13 +6,34 @@
"dev": "astro dev", "dev": "astro dev",
"build": "astro build", "build": "astro build",
"preview": "astro preview", "preview": "astro preview",
"astro": "astro" "astro": "astro",
"lint": "eslint .",
"check": "astro check",
"prepare": "husky"
}, },
"dependencies": { "dependencies": {
"@astrojs/check": "^0.9.6",
"@astrojs/mdx": "^4.3.13", "@astrojs/mdx": "^4.3.13",
"@astrojs/rss": "^4.0.14", "@astrojs/rss": "^4.0.14",
"@astrojs/sitemap": "^3.6.0", "@astrojs/sitemap": "^3.6.0",
"astro": "^5.16.6", "astro": "^5.16.6",
"sharp": "^0.34.3" "sharp": "^0.34.3"
},
"devDependencies": {
"@commitlint/cli": "^20.3.1",
"@commitlint/config-conventional": "^20.3.1",
"@typescript-eslint/eslint-plugin": "^8.52.0",
"@typescript-eslint/parser": "^8.52.0",
"astro-eslint-parser": "^1.2.2",
"eslint": "^9.39.2",
"eslint-plugin-astro": "^1.5.0",
"husky": "^9.1.7",
"typescript": "^5.9.3"
},
"pnpm": {
"onlyBuiltDependencies": [
"esbuild",
"sharp"
]
} }
} }

2126
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

3
pnpm-workspace.yaml Normal file
View File

@@ -0,0 +1,3 @@
ignoredBuiltDependencies:
- esbuild
- sharp

View File

@@ -1,6 +1,5 @@
{ {
"extends": "astro/tsconfigs/strict", "extends": "astro/tsconfigs/strict",
"include": [".astro/types.d.ts", "**/*"],
"exclude": ["dist"], "exclude": ["dist"],
"compilerOptions": { "compilerOptions": {
"strictNullChecks": true "strictNullChecks": true