mirror of
https://github.com/arthur-pbty/links.git
synced 2026-08-01 20:29:27 +02:00
update runner
This commit is contained in:
+9
-1
@@ -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
|
||||
@@ -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
|
||||
echo "Pull latest code"
|
||||
git pull origin main
|
||||
|
||||
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
|
||||
git pull origin main
|
||||
fi
|
||||
echo "Build & restart containers"
|
||||
docker compose down || true
|
||||
docker compose build
|
||||
docker compose up -d
|
||||
|
||||
if [ -n \"$ENV_CONTENT\" ]; then
|
||||
echo \"$ENV_CONTENT\" > .env
|
||||
fi
|
||||
|
||||
docker compose up -d --build
|
||||
"
|
||||
echo "Deploy finished"
|
||||
+25
@@ -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
@@ -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
|
||||
Reference in New Issue
Block a user