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:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
concurrency:
|
||||
group: production-deploy
|
||||
cancel-in-progress: true
|
||||
branches: ["main"]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Deploy portfolio Production
|
||||
shell: bash
|
||||
- name: Deploy on server
|
||||
run: |
|
||||
set -euo pipefail
|
||||
set -e
|
||||
|
||||
echo "============================"
|
||||
echo " Starting deployment"
|
||||
echo "============================"
|
||||
echo "Go to app folder"
|
||||
cd /opt/apps/portfolio
|
||||
|
||||
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..."
|
||||
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"
|
||||
echo "Deploy finished"
|
||||
+6
-22
@@ -1,44 +1,28 @@
|
||||
# ====== 1. Dependencies ======
|
||||
FROM node:20-alpine AS deps
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm ci
|
||||
|
||||
|
||||
# ====== 2. Build ======
|
||||
# ===== BUILD =====
|
||||
FROM node:20-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Variables build-time
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
COPY . .
|
||||
|
||||
RUN npm run build
|
||||
|
||||
|
||||
# ====== 3. Runner (prod minimal) ======
|
||||
# ===== RUN =====
|
||||
FROM node:20-alpine AS runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# user non-root (bonne pratique)
|
||||
RUN addgroup -S nextjs && adduser -S nextjs -G nextjs
|
||||
|
||||
# Copy standalone output
|
||||
# Standalone output
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
+9
-7
@@ -1,20 +1,22 @@
|
||||
services:
|
||||
next-app:
|
||||
visio:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
|
||||
container_name: portfolio-app
|
||||
container_name: portfolio
|
||||
|
||||
ports:
|
||||
- "${WEB_PORT}:3000"
|
||||
- "${APP_PORT}:3000"
|
||||
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
restart: unless-stopped
|
||||
|
||||
environment:
|
||||
- PORT=3000
|
||||
- NODE_ENV=production
|
||||
- HOSTNAME=0.0.0.0
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 20s
|
||||
+1
-6
@@ -1,14 +1,9 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
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",
|
||||
|
||||
// Compression des pages côté serveur (gzip/brotli)
|
||||
compress: true,
|
||||
poweredByHeader: false,
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
||||
+2
-1
@@ -6,7 +6,8 @@
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"start": "node .next/standalone/server.js",
|
||||
"docker": "docker compose up --build",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user