feat: add Dockerfile, nginx config and K8s manifests
Some checks failed
Build & Deploy to K3s / build-and-deploy (push) Failing after 11s

This commit is contained in:
ordinarthur 2026-04-11 11:52:08 +02:00
parent 4e3e4bb708
commit ec064db204
7 changed files with 149 additions and 0 deletions

6
.dockerignore Normal file
View File

@ -0,0 +1,6 @@
node_modules
dist
.git
.astro
.DS_Store
.claude

25
Dockerfile Normal file
View File

@ -0,0 +1,25 @@
# --- Stage 1: Build ---
FROM node:22-alpine AS build
WORKDIR /app
# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# Install dependencies first (cache layer)
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# Copy source and build
COPY . .
RUN pnpm build
# --- Stage 2: Serve ---
FROM nginx:alpine AS runtime
# Custom nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built static files
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80

43
k8s/deployment.yml Normal file
View File

@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: aurelie-portfolio
namespace: portfolio
labels:
app: aurelie-portfolio
spec:
replicas: 2
selector:
matchLabels:
app: aurelie-portfolio
template:
metadata:
labels:
app: aurelie-portfolio
spec:
containers:
- name: aurelie-portfolio
image: git.arthurbarre.fr/ordinarthur/aurelie-portfolio:latest
ports:
- containerPort: 80
resources:
requests:
memory: "64Mi"
cpu: "50m"
limits:
memory: "128Mi"
cpu: "200m"
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 30
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 3
periodSeconds: 10
imagePullSecrets:
- name: gitea-registry-secret

35
k8s/ingress.yml Normal file
View File

@ -0,0 +1,35 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: aurelie-portfolio
namespace: portfolio
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: websecure
traefik.ingress.kubernetes.io/router.tls: "true"
traefik.ingress.kubernetes.io/router.tls.certresolver: letsencrypt
spec:
rules:
- host: aureliebarre.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: aurelie-portfolio
port:
number: 80
- host: www.aureliebarre.fr
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: aurelie-portfolio
port:
number: 80
tls:
- hosts:
- aureliebarre.fr
- www.aureliebarre.fr

4
k8s/namespace.yml Normal file
View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: portfolio

14
k8s/service.yml Normal file
View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: aurelie-portfolio
namespace: portfolio
spec:
type: NodePort
selector:
app: aurelie-portfolio
ports:
- port: 80
targetPort: 80
nodePort: 30081
protocol: TCP

22
nginx.conf Normal file
View File

@ -0,0 +1,22 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Cache static assets
location ~* \.(jpg|jpeg|png|gif|ico|svg|css|js|woff2?)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
# Astro clean URLs fallback
location / {
try_files $uri $uri/ $uri.html /index.html;
}
# Gzip
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml image/svg+xml;
gzip_min_length 256;
}