mirror of
https://github.com/arthur-pbty/reducelink.git
synced 2026-08-01 20:29:47 +02:00
add runner
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules
|
||||||
|
.next
|
||||||
|
npm-debug.log
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
.git
|
||||||
@@ -3,3 +3,12 @@ NEXT_PUBLIC_BASE_URL=https://reducelink.arthurp.fr
|
|||||||
|
|
||||||
# Base de données SQLite
|
# Base de données SQLite
|
||||||
DATABASE_URL="file:./dev.db"
|
DATABASE_URL="file:./dev.db"
|
||||||
|
|
||||||
|
# Port exposé côté machine
|
||||||
|
APP_PORT=3000
|
||||||
|
|
||||||
|
# Node environment
|
||||||
|
NODE_ENV=production
|
||||||
|
|
||||||
|
# Next.js
|
||||||
|
PORT=3000
|
||||||
@@ -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/reducelink
|
||||||
|
|
||||||
|
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"
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
# ===== BUILD =====
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
|
||||||
|
# ===== RUN =====
|
||||||
|
FROM node:20-alpine AS runner
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
# Standalone output
|
||||||
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder /app/.next/standalone ./
|
||||||
|
COPY --from=builder /app/.next/static ./.next/static
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["node", "server.js"]
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
services:
|
|
||||||
reducelink:
|
|
||||||
image: node:20-alpine
|
|
||||||
container_name: reducelink
|
|
||||||
working_dir: /app
|
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
- node_modules:/app/node_modules
|
|
||||||
ports:
|
|
||||||
- "3000:3000"
|
|
||||||
environment:
|
|
||||||
- NODE_ENV=development
|
|
||||||
- DATABASE_URL=file:./prisma/dev.db
|
|
||||||
- NEXT_PUBLIC_BASE_URL=http://localhost:3000
|
|
||||||
command: sh -c "npm install && npx prisma generate && npx prisma migrate dev --name init && npm run dev"
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
node_modules:
|
|
||||||
+16
-12
@@ -1,18 +1,22 @@
|
|||||||
services:
|
services:
|
||||||
reducelink:
|
reducelink:
|
||||||
image: node:20-alpine
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
|
||||||
container_name: reducelink
|
container_name: reducelink
|
||||||
working_dir: /app
|
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
- node_modules:/app/node_modules
|
|
||||||
ports:
|
ports:
|
||||||
- "3006:3000"
|
- "${APP_PORT}:3000"
|
||||||
environment:
|
|
||||||
- DATABASE_URL=file:./dev.db
|
env_file:
|
||||||
- NEXT_PUBLIC_BASE_URL=https://reducelink.arthurp.fr
|
- .env
|
||||||
command: sh -c "apk add --no-cache openssl libc6-compat && npm install && npx prisma generate && npx prisma migrate deploy && npm run build && npm run start"
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
healthcheck:
|
||||||
node_modules:
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 20s
|
||||||
@@ -3,6 +3,7 @@ import type { NextConfig } from "next";
|
|||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
compress: true,
|
compress: true,
|
||||||
poweredByHeader: false,
|
poweredByHeader: false,
|
||||||
|
output: "standalone",
|
||||||
async headers() {
|
async headers() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-1
@@ -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": {
|
||||||
|
|||||||
Reference in New Issue
Block a user