diff --git a/.env.dist b/.env.dist new file mode 100644 index 0000000..730f570 --- /dev/null +++ b/.env.dist @@ -0,0 +1 @@ +CADDY_VERSION=2.10.2 \ No newline at end of file diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..aa46b45 --- /dev/null +++ b/Caddyfile @@ -0,0 +1,9 @@ +:80 { + root * /usr/share/caddy + file_server + + # Client cache + header { + Cache-Control "public, max-age=86400" + } +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..614f65f --- /dev/null +++ b/Dockerfile @@ -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 \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..2140067 --- /dev/null +++ b/Jenkinsfile @@ -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." } + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9a1f4a1 --- /dev/null +++ b/docker-compose.yml @@ -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 \ No newline at end of file diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 96c2fce..e63f14a 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -3,7 +3,7 @@ const today = new Date(); ---