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
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
# ===== BUILD =====
FROM node:20-alpine AS builder
FROM base AS deps
COPY package.json package-lock.json ./
WORKDIR /app
COPY package*.json ./
RUN npm ci
FROM deps AS dev
COPY . .
EXPOSE 3000
CMD ["npm", "run", "dev", "--", "--hostname", "0.0.0.0", "--port", "3000"]
FROM deps AS builder
COPY . .
RUN npm run build
FROM base AS runner
# ===== RUN =====
FROM node:20-alpine AS runner
WORKDIR /app
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/static ./.next/static
COPY --from=builder /app/public ./public
EXPOSE 3000
CMD ["node", "server.js"]
+18 -26
View File
@@ -3,6 +3,8 @@ services:
image: postgres:16-alpine
container_name: contact-postgres
restart: unless-stopped
env_file:
- .env
environment:
POSTGRES_DB: ${POSTGRES_DB:-contact}
POSTGRES_USER: ${POSTGRES_USER:-contact}
@@ -12,43 +14,33 @@ services:
volumes:
- postgres-data:/var/lib/postgresql/data
contact-dev:
profiles: ["dev"]
contact:
build:
context: .
target: dev
container_name: contact-dev
ports:
- "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
dockerfile: Dockerfile
container_name: contact
contact-prod:
profiles: ["prod"]
build:
context: .
target: runner
container_name: contact-prod
restart: unless-stopped
ports:
- "3018:3000"
- "${APP_PORT}:3000"
env_file:
- .env
environment:
NEXT_TELEMETRY_DISABLED: "1"
DATABASE_URL: ${DATABASE_URL_DOCKER:-postgresql://contact:change-this-db-password@postgres:5432/contact}
restart: unless-stopped
depends_on:
- postgres
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
volumes:
postgres-data:
+2
View File
@@ -2,6 +2,8 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = {
output: "standalone",
compress: true,
poweredByHeader: false,
};
export default nextConfig;
+2 -1
View File
@@ -5,7 +5,8 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"start": "node .next/standalone/server.js",
"docker": "docker compose up --build",
"lint": "eslint"
},
"dependencies": {