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