update runner

This commit is contained in:
Puechberty Arthur
2026-06-11 01:06:48 +02:00
parent f0c7de95de
commit 5679ea30d2
4 changed files with 68 additions and 43 deletions
+9 -1
View File
@@ -1,4 +1,12 @@
ADMIN_USERNAME=change-me
ADMIN_USERNAME=admin
ADMIN_PASSWORD=change-me
ADMIN_SESSION_SECRET=replace-with-a-long-random-secret
# Port exposé côté machine
APP_PORT=3000
# Node environment
NODE_ENV=production
# Next.js
PORT=3000
+13 -28
View File
@@ -1,42 +1,27 @@
name: Deploy to VM Prod
name: Deploy Docker
on:
push:
branches:
- main
branches: ["main"]
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Deploy to production
- name: Deploy on server
run: |
REPO_NAME=${{ github.event.repository.name }}
set -e
if [ -z "${{ secrets.ENV_FILE }}" ]; then
ENV_CONTENT=""
else
ENV_CONTENT="${{ secrets.ENV_FILE }}"
fi
echo "Go to app folder"
cd /opt/apps/links
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "
mkdir -p /srv/$REPO_NAME
cd /srv/$REPO_NAME
if [ ! -d .git ]; then
rm -rf ./* # vide le dossier si nécessaire
git clone https://github.com/arthur-pbty-labs/$REPO_NAME .
else
git reset --hard
echo "Pull latest code"
git pull origin main
fi
if [ -n \"$ENV_CONTENT\" ]; then
echo \"$ENV_CONTENT\" > .env
fi
echo "Build & restart containers"
docker compose down || true
docker compose build
docker compose up -d
docker compose up -d --build
"
echo "Deploy finished"
+25
View File
@@ -0,0 +1,25 @@
# ===== 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
COPY --from=builder /app ./
EXPOSE 3000
CMD ["npm", "start"]
+19 -12
View File
@@ -1,15 +1,22 @@
services:
app:
image: node:20
working_dir: /usr/src/app
volumes:
- ./:/usr/src/app
links:
build:
context: .
dockerfile: Dockerfile
container_name: links
ports:
- "3000:3000"
- "${APP_PORT}:3000"
env_file:
- .env
restart: unless-stopped
environment:
- PORT=${PORT:-3000}
- ADMIN_USERNAME=${ADMIN_USERNAME}
- ADMIN_PASSWORD=${ADMIN_PASSWORD}
- ADMIN_SESSION_SECRET=${ADMIN_SESSION_SECRET}
command: sh -c "npm install && npm run build && npm start"
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s