mirror of
https://github.com/arthur-pbty/portfolio.git
synced 2026-08-01 20:29:43 +02:00
update runner
This commit is contained in:
@@ -1,45 +1,27 @@
|
|||||||
name: Deploy Production
|
name: Deploy Docker
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: ["main"]
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: production-deploy
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy portfolio Production
|
- name: Deploy on server
|
||||||
shell: bash
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -e
|
||||||
|
|
||||||
echo "============================"
|
echo "Go to app folder"
|
||||||
echo " Starting deployment"
|
cd /opt/apps/portfolio
|
||||||
echo "============================"
|
|
||||||
|
|
||||||
APP_DIR="/srv/apps/portfolio"
|
echo "Pull latest code"
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
cd "$APP_DIR"
|
echo "Build & restart containers"
|
||||||
|
docker compose down || true
|
||||||
|
docker compose build
|
||||||
|
docker compose up -d
|
||||||
|
|
||||||
echo "Fetching latest code..."
|
echo "Deploy finished"
|
||||||
git fetch origin main
|
|
||||||
|
|
||||||
echo "Resetting local state..."
|
|
||||||
git reset --hard origin/main
|
|
||||||
|
|
||||||
echo "Cleaning untracked files (keeping .env)"
|
|
||||||
git clean -fd -e .env
|
|
||||||
|
|
||||||
echo "Pulling/building containers..."
|
|
||||||
docker compose pull || true
|
|
||||||
docker compose up -d --build --remove-orphans
|
|
||||||
|
|
||||||
echo "Cleaning unused Docker images..."
|
|
||||||
docker image prune -f
|
|
||||||
|
|
||||||
echo "Deployment finished successfully"
|
|
||||||
+6
-22
@@ -1,44 +1,28 @@
|
|||||||
# ====== 1. Dependencies ======
|
# ===== BUILD =====
|
||||||
FROM node:20-alpine AS deps
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY package.json package-lock.json* ./
|
|
||||||
RUN npm ci
|
|
||||||
|
|
||||||
|
|
||||||
# ====== 2. Build ======
|
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY package*.json ./
|
||||||
COPY . .
|
RUN npm ci
|
||||||
|
|
||||||
# Variables build-time
|
COPY . .
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
|
||||||
# ====== 3. Runner (prod minimal) ======
|
# ===== RUN =====
|
||||||
FROM node:20-alpine AS runner
|
FROM node:20-alpine AS runner
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1
|
|
||||||
|
|
||||||
# user non-root (bonne pratique)
|
# Standalone output
|
||||||
RUN addgroup -S nextjs && adduser -S nextjs -G nextjs
|
|
||||||
|
|
||||||
# Copy standalone output
|
|
||||||
COPY --from=builder /app/public ./public
|
COPY --from=builder /app/public ./public
|
||||||
COPY --from=builder /app/.next/standalone ./
|
COPY --from=builder /app/.next/standalone ./
|
||||||
COPY --from=builder /app/.next/static ./.next/static
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
|
|
||||||
USER nextjs
|
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
CMD ["node", "server.js"]
|
CMD ["node", "server.js"]
|
||||||
+9
-7
@@ -1,20 +1,22 @@
|
|||||||
services:
|
services:
|
||||||
next-app:
|
visio:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
|
|
||||||
container_name: portfolio-app
|
container_name: portfolio
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "${WEB_PORT}:3000"
|
- "${APP_PORT}:3000"
|
||||||
|
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
environment:
|
healthcheck:
|
||||||
- PORT=3000
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/"]
|
||||||
- NODE_ENV=production
|
interval: 30s
|
||||||
- HOSTNAME=0.0.0.0
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 20s
|
||||||
+1
-6
@@ -1,14 +1,9 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
// Mode production strict pour React (détecte les erreurs tôt)
|
|
||||||
reactStrictMode: true,
|
|
||||||
|
|
||||||
// Build standalone pour Docker → image finale légère et indépendante
|
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
|
|
||||||
// Compression des pages côté serveur (gzip/brotli)
|
|
||||||
compress: true,
|
compress: true,
|
||||||
|
poweredByHeader: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|||||||
+2
-1
@@ -6,7 +6,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "node .next/standalone/server.js",
|
||||||
|
"docker": "docker compose up --build",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix"
|
"lint:fix": "eslint . --fix"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user