add runner

This commit is contained in:
Puechberty Arthur
2026-06-11 13:53:27 +02:00
parent 7c22c4f22e
commit 4dbc7c2960
7 changed files with 66 additions and 48 deletions
+27
View File
@@ -0,0 +1,27 @@
name: Deploy Docker
on:
push:
branches: ["main"]
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Deploy on server
run: |
set -e
echo "Go to app folder"
cd /opt/apps/contact
echo "Pull latest code"
git pull origin main
echo "Build & restart containers"
docker compose down || true
docker compose build
docker compose up -d
echo "Deploy finished"
-5
View File
@@ -1,5 +0,0 @@
<!-- BEGIN:nextjs-agent-rules -->
# This is NOT the Next.js you know
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
<!-- END:nextjs-agent-rules -->
-1
View File
@@ -1 +0,0 @@
@AGENTS.md
+16 -14
View File
@@ -1,26 +1,28 @@
FROM node:22-alpine AS base # ===== BUILD =====
WORKDIR /app FROM node:20-alpine AS builder
ENV NEXT_TELEMETRY_DISABLED=1
FROM base AS deps WORKDIR /app
COPY package.json package-lock.json ./
COPY package*.json ./
RUN npm ci RUN npm ci
FROM deps AS dev
COPY . . COPY . .
EXPOSE 3000
CMD ["npm", "run", "dev", "--", "--hostname", "0.0.0.0", "--port", "3000"]
FROM deps AS builder
COPY . .
RUN npm run build RUN npm run build
FROM base AS runner
# ===== RUN =====
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
ENV HOSTNAME=0.0.0.0
ENV PORT=3000 # Standalone output
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
COPY --from=builder /app/public ./public
EXPOSE 3000 EXPOSE 3000
CMD ["node", "server.js"] CMD ["node", "server.js"]
+18 -26
View File
@@ -3,6 +3,8 @@ services:
image: postgres:16-alpine image: postgres:16-alpine
container_name: contact-postgres container_name: contact-postgres
restart: unless-stopped restart: unless-stopped
env_file:
- .env
environment: environment:
POSTGRES_DB: ${POSTGRES_DB:-contact} POSTGRES_DB: ${POSTGRES_DB:-contact}
POSTGRES_USER: ${POSTGRES_USER:-contact} POSTGRES_USER: ${POSTGRES_USER:-contact}
@@ -12,43 +14,33 @@ services:
volumes: volumes:
- postgres-data:/var/lib/postgresql/data - postgres-data:/var/lib/postgresql/data
contact-dev: contact:
profiles: ["dev"]
build: build:
context: . context: .
target: dev dockerfile: Dockerfile
container_name: contact-dev
ports: container_name: contact
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
- /app/.next
environment:
NEXT_TELEMETRY_DISABLED: "1"
DATABASE_URL: ${DATABASE_URL_DOCKER:-postgresql://contact:change-this-db-password@postgres:5432/contact}
ADMIN_USERNAME: ${ADMIN_USERNAME:-admin}
ADMIN_PASSWORD: ${ADMIN_PASSWORD:-change-this-admin-password}
ADMIN_SESSION_SECRET: ${ADMIN_SESSION_SECRET:-change-this-session-secret}
depends_on:
- postgres
contact-prod:
profiles: ["prod"]
build:
context: .
target: runner
container_name: contact-prod
restart: unless-stopped
ports: ports:
- "3018:3000" - "${APP_PORT}:3000"
env_file: env_file:
- .env - .env
environment: environment:
NEXT_TELEMETRY_DISABLED: "1" NEXT_TELEMETRY_DISABLED: "1"
DATABASE_URL: ${DATABASE_URL_DOCKER:-postgresql://contact:change-this-db-password@postgres:5432/contact} DATABASE_URL: ${DATABASE_URL_DOCKER:-postgresql://contact:change-this-db-password@postgres:5432/contact}
restart: unless-stopped
depends_on: depends_on:
- postgres - postgres
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
volumes: volumes:
postgres-data: postgres-data:
+2
View File
@@ -2,6 +2,8 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
output: "standalone", output: "standalone",
compress: true,
poweredByHeader: false,
}; };
export default nextConfig; export default nextConfig;
+2 -1
View File
@@ -5,7 +5,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"
}, },
"dependencies": { "dependencies": {