Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Fix deploy

Veauville Raphael47ecff76acad
diff --git a/.github/workflows/deploy_to_prod.yml b/.github/workflows/deploy_to_prod.yml
index bd1431bf..473a228a 100755
--- a/.github/workflows/deploy_to_prod.yml
+++ b/.github/workflows/deploy_to_prod.yml
@@ -1,65 +1,46 @@
-name: Deploy to production
+name: Build & deploy to VPS
+
on:
push:
- branches: [main]
+ branches:
+ - main
+
jobs:
- prepar:
- runs-on: self-hosted
+ build:
+ runs-on: ubuntu-latest
+
steps:
- - name: Prepar for build
- env:
- NODE_ENV: development
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ - name: Install dependencies
run: |
- cd /home/smaug/sites/alexandrie/
- git reset --hard HEAD
- git pull origin main --force
- build-backend:
- runs-on: self-hosted
- needs: prepar
- steps:
- - name: Build backend
- env:
- NODE_ENV: development
- run: |
- cd /home/smaug/sites/alexandrie/backend
- npm ci
- npm run build --if-present
- build-frontend:
- runs-on: self-hosted
- needs: prepar
- steps:
+ cd frontend
+ npm install
+ cd ../dashboard
+ npm install
+ cd ../backend
+ npm install
+
- name: Build frontend
- env:
- NODE_ENV: development
run: |
- cd /home/smaug/sites/alexandrie/frontend
- npm ci
- npm run build --if-present
- build-dashboard:
- runs-on: self-hosted
- needs: prepar
- steps:
+ cd frontend
+ npm run build
+
- name: Build dashboard
- env:
- NODE_ENV: development
run: |
- cd /home/smaug/sites/alexandrie/dashboard
- npm ci
- npm run build --if-present
- deploy:
- runs-on: self-hosted
- needs: [build-backend, build-frontend, build-dashboard]
- steps:
- - name: Deploy to production
- env:
- NODE_ENV: production
- DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
- DATABASE_USER: ${{ secrets.DATABASE_USER }}
- JWT_SECRET: ${{ secrets.JWT_SECRET }}
- PORT: 8101
- DOMAIN_CLIENT: https://alexandrie-hub.fr
- DOMAIN_DASHBOARD: https://dashboard.alexandrie-hub.fr
- FRONT_DOMAIN: alexandrie-hub.fr
+ cd dashboard
+ npm run build
+
+ - name: Build backend
run: |
- cd /home/smaug/sites/alexandrie/
- pm2 reload ecosystem.config.js --update-env
+ cd backend
+ npm run build
+- name: Deploy to VPS
+ run: |
+ echo "$DEPLOY_KEY" > deploy_key
+ scp -i deploy_key -r --exclude=src frontend/* ${{secrets.ssh_host}}:/home/smaug/sites/alexandrie/frontend
+ scp -i deploy_key -r --exclude=src dashboard/* ${{secrets.ssh_host}}:/home/smaug/sites/alexandrie/dashboard
+ scp -i deploy_key -r --exclude=src backend/* ${{secrets.ssh_host}}:/home/smaug/sites/alexandrie/backend
+ env:
+ DEPLOY_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
\ No newline at end of file
diff --git a/ecosystem.config.js b/ecosystem.config.js
new file mode 100644
index 00000000..28216772
--- /dev/null
+++ b/ecosystem.config.js
@@ -0,0 +1,28 @@
+module.exports = {
+ apps: [
+ {
+ name: 'alexandrie-backend',
+ cwd: './backend/dist',
+ script: 'node main.js',
+ env: {
+ NODE_ENV: 'production',
+ },
+ },
+ {
+ name: 'alexandrie-frontend',
+ cwd: './frontend',
+ script: 'PORT=8100 node .output/server/index.mjs',
+ env: {
+ NODE_ENV: 'production',
+ },
+ },
+ {
+ name: 'alexandrie-dashboard',
+ cwd: './dashboard',
+ script: 'PORT=8102 node .output/server/index.mjs',
+ env: {
+ NODE_ENV: 'production',
+ },
+ },
+ ],
+};