mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: move the files and modified the en
This commit is contained in:
parent
1534a02953
commit
59bbc43fc4
43
.github/workflows/deploy_web.yaml
vendored
43
.github/workflows/deploy_web.yaml
vendored
@ -1,15 +1,28 @@
|
|||||||
name: Deploy
|
name: Deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- build/test
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
environment:
|
environment:
|
||||||
description: 'Environment'
|
description: 'Environment'
|
||||||
required: true
|
required: true
|
||||||
default: 'test'
|
default: 'test'
|
||||||
|
port:
|
||||||
|
description: 'Docker Port'
|
||||||
|
required: true
|
||||||
|
default: '30012'
|
||||||
|
api_base_url:
|
||||||
|
description: 'API Base URL'
|
||||||
|
required: true
|
||||||
|
default: 'https://test.appflowy.cloud'
|
||||||
|
api_gotrue_url:
|
||||||
|
description: 'GoTrue API URL'
|
||||||
|
required: true
|
||||||
|
default: 'https://test.appflowy.cloud/gotrue'
|
||||||
|
ws_url:
|
||||||
|
description: 'Websocket URL'
|
||||||
|
required: true
|
||||||
|
default: 'wss://test.appflowy.cloud/ws/v1'
|
||||||
env:
|
env:
|
||||||
NODE_VERSION: "18.16.0"
|
NODE_VERSION: "18.16.0"
|
||||||
PNPM_VERSION: "8.5.0"
|
PNPM_VERSION: "8.5.0"
|
||||||
@ -40,16 +53,12 @@ jobs:
|
|||||||
working-directory: frontend/appflowy_web_app
|
working-directory: frontend/appflowy_web_app
|
||||||
run: |
|
run: |
|
||||||
pnpm install
|
pnpm install
|
||||||
- name: generate env file (Test)
|
- name: generate env file
|
||||||
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test'
|
|
||||||
working-directory: frontend/appflowy_web_app
|
working-directory: frontend/appflowy_web_app
|
||||||
run: |
|
run: |
|
||||||
cp test.env .env
|
echo "AF_BASE_URL=${{ github.event.inputs.api_base_url }}" >> .env
|
||||||
- name: generate env file (Prod)
|
echo "AF_GOTRUE_URL=${{ github.event.inputs.api_gotrue_url }}" >> .env
|
||||||
if: github.event.inputs.environment == 'prod'
|
echo "AF_WS_URL=${{ github.event.inputs.ws_url }}" >> .env
|
||||||
working-directory: frontend/appflowy_web_app
|
|
||||||
run: |
|
|
||||||
cp beta.env .env
|
|
||||||
- name: test and lint
|
- name: test and lint
|
||||||
working-directory: frontend/appflowy_web_app
|
working-directory: frontend/appflowy_web_app
|
||||||
run: |
|
run: |
|
||||||
@ -61,22 +70,22 @@ jobs:
|
|||||||
- name: Archive build output
|
- name: Archive build output
|
||||||
working-directory: frontend/appflowy_web_app
|
working-directory: frontend/appflowy_web_app
|
||||||
run: |
|
run: |
|
||||||
tar -czf build-output.tar.gz dist server.cjs start.sh Dockerfile nginx.conf .env supervisord.conf
|
tar -czf build-output.tar.gz dist deploy/server.cjs deploy/start.sh deploy/Dockerfile deploy/nginx.conf .env deploy/supervisord.conf
|
||||||
|
|
||||||
- name: Deploy to EC2 (Test)
|
- name: Deploy to EC2 (Test)
|
||||||
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test'
|
if: github.event.inputs.environment == 'test'
|
||||||
uses: easingthemes/ssh-deploy@main
|
uses: easingthemes/ssh-deploy@main
|
||||||
with:
|
with:
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.WEB_TEST_SSH_PRIVATE_KEY }}
|
SSH_PRIVATE_KEY: ${{ secrets.WEB_TEST_SSH_PRIVATE_KEY }}
|
||||||
ARGS: "-rlgoDzvc -i"
|
ARGS: "-rlgoDzvc -i"
|
||||||
SOURCE: frontend/appflowy_web_app/build-output.tar.gz frontend/appflowy_web_app/deploy.sh
|
SOURCE: frontend/appflowy_web_app/build-output.tar.gz frontend/appflowy_web_app/deploy/deploy.sh
|
||||||
TARGET: /home/${{ secrets.WEB_TEST_REMOTE_USER }}/appflowy-web-app
|
TARGET: /home/${{ secrets.WEB_TEST_REMOTE_USER }}/appflowy-web-app
|
||||||
REMOTE_HOST: ${{ secrets.WEB_TEST_REMOTE_HOST }}
|
REMOTE_HOST: ${{ secrets.WEB_TEST_REMOTE_HOST }}
|
||||||
REMOTE_USER: ${{ secrets.WEB_TEST_REMOTE_USER }}
|
REMOTE_USER: ${{ secrets.WEB_TEST_REMOTE_USER }}
|
||||||
SCRIPT_AFTER: |
|
SCRIPT_AFTER: |
|
||||||
cd appflowy-web-app
|
cd appflowy-web-app
|
||||||
chmod +x deploy.sh
|
chmod +x deploy.sh
|
||||||
sh deploy.sh
|
sh deploy.sh ${{ github.event.inputs.port }}
|
||||||
- name: Deploy to EC2 (Prod)
|
- name: Deploy to EC2 (Prod)
|
||||||
if: github.event.inputs.environment == 'prod'
|
if: github.event.inputs.environment == 'prod'
|
||||||
uses: easingthemes/ssh-deploy@main
|
uses: easingthemes/ssh-deploy@main
|
||||||
@ -84,10 +93,10 @@ jobs:
|
|||||||
SSH_PRIVATE_KEY: ${{ secrets.WEB_PROD_SSH_PRIVATE_KEY }}
|
SSH_PRIVATE_KEY: ${{ secrets.WEB_PROD_SSH_PRIVATE_KEY }}
|
||||||
ARGS: "-rlgoDzvc -i"
|
ARGS: "-rlgoDzvc -i"
|
||||||
TARGET: /home/${{ secrets.WEB_PROD_REMOTE_USER }}/appflowy-web-app
|
TARGET: /home/${{ secrets.WEB_PROD_REMOTE_USER }}/appflowy-web-app
|
||||||
SOURCE: frontend/appflowy_web_app/build-output.tar.gz frontend/appflowy_web_app/deploy.sh
|
SOURCE: frontend/appflowy_web_app/build-output.tar.gz frontend/appflowy_web_app/deploy/deploy.sh
|
||||||
REMOTE_HOST: ${{ secrets.WEB_PROD_REMOTE_HOST }}
|
REMOTE_HOST: ${{ secrets.WEB_PROD_REMOTE_HOST }}
|
||||||
REMOTE_USER: ${{ secrets.WEB_PROD_REMOTE_USER }}
|
REMOTE_USER: ${{ secrets.WEB_PROD_REMOTE_USER }}
|
||||||
SCRIPT_AFTER: |
|
SCRIPT_AFTER: |
|
||||||
cd appflowy-web-app
|
cd appflowy-web-app
|
||||||
chmod +x deploy.sh
|
chmod +x deploy.sh
|
||||||
sh deploy.sh
|
sh deploy.sh ${{ github.event.inputs.port }}
|
@ -43,6 +43,16 @@ Before you begin, ensure you have the following installed:
|
|||||||
pnpm install
|
pnpm install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- Modify the environment file in `frontend/appflowy_web_app/.env` to add or modify environment variables
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Example
|
||||||
|
AF_BASE_URL=https://test.appflowy.cloud
|
||||||
|
AF_GOTRUE_URL=https://test.appflowy.cloud/gotrue
|
||||||
|
AF_WS_URL=wss://test.appflowy.cloud/ws/v1
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
#### 🖥️ Desktop Application (Tauri) (Optional)
|
#### 🖥️ Desktop Application (Tauri) (Optional)
|
||||||
|
|
||||||
> **Note**: if you want to run the web app in the browser, skip this step
|
> **Note**: if you want to run the web app in the browser, skip this step
|
||||||
@ -148,10 +158,6 @@ Don't modify the theme file in `frontend/appflowy_web_app/src/styles/variables`
|
|||||||
pnpm run css:variables
|
pnpm run css:variables
|
||||||
```
|
```
|
||||||
|
|
||||||
#### How to add or modify the environment variables
|
|
||||||
|
|
||||||
- Modify the environment file in `frontend/appflowy_web_app/.env` to add or modify environment variables
|
|
||||||
|
|
||||||
#### How to create symlink for the @appflowyinc/client-api-wasm in local development
|
#### How to create symlink for the @appflowyinc/client-api-wasm in local development
|
||||||
|
|
||||||
- Run the following command to create a symlink for the @appflowyinc/client-api-wasm
|
- Run the following command to create a symlink for the @appflowyinc/client-api-wasm
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
AF_WS_URL=wss://beta.appflowy.cloud/ws/v1
|
|
||||||
AF_BASE_URL=https://beta.appflowy.cloud
|
|
||||||
AF_GOTRUE_URL=https://beta.appflowy.cloud/gotrue
|
|
@ -1,13 +0,0 @@
|
|||||||
rm -rf dist
|
|
||||||
|
|
||||||
tar -xzf build-output.tar.gz
|
|
||||||
|
|
||||||
rm -rf build-output.tar.gz
|
|
||||||
|
|
||||||
docker system prune -f
|
|
||||||
|
|
||||||
docker build -t appflowy-web-app .
|
|
||||||
|
|
||||||
docker rm -f appflowy-web-app || true
|
|
||||||
|
|
||||||
docker run -d --env-file .env -p 30012:80 --restart always --name appflowy-web-app appflowy-web-app
|
|
@ -7,7 +7,7 @@ RUN apt-get update && \
|
|||||||
|
|
||||||
RUN bun install cheerio pino pino-pretty
|
RUN bun install cheerio pino pino-pretty
|
||||||
|
|
||||||
COPY . .
|
COPY .. .
|
||||||
|
|
||||||
COPY supervisord.conf /app/supervisord.conf
|
COPY supervisord.conf /app/supervisord.conf
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ RUN addgroup --system nginx && \
|
|||||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|
||||||
COPY dist/ /usr/share/nginx/html/
|
COPY ../dist /usr/share/nginx/html/
|
||||||
|
|
||||||
COPY nginx.conf /etc/nginx/nginx.conf
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
22
frontend/appflowy_web_app/deploy/deploy.sh
Normal file
22
frontend/appflowy_web_app/deploy/deploy.sh
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "No port number provided"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PORT=$1
|
||||||
|
|
||||||
|
echo "Starting deployment on port $PORT"
|
||||||
|
|
||||||
|
rm -rf dist
|
||||||
|
|
||||||
|
tar -xzf build-output.tar.gz
|
||||||
|
|
||||||
|
rm -rf build-output.tar.gz
|
||||||
|
|
||||||
|
docker system prune -f
|
||||||
|
|
||||||
|
docker build -t appflowy-web-app-"$PORT" .
|
||||||
|
|
||||||
|
docker rm -f appflowy-web-app-"$PORT" || true
|
||||||
|
|
||||||
|
docker run -d --env-file .env -p "$PORT":80 --restart always --name appflowy-web-app-"$PORT" appflowy-web-app-"$PORT"
|
@ -6,7 +6,7 @@ const { fetch } = require('bun');
|
|||||||
|
|
||||||
const distDir = path.join(__dirname, 'dist');
|
const distDir = path.join(__dirname, 'dist');
|
||||||
const indexPath = path.join(distDir, 'index.html');
|
const indexPath = path.join(distDir, 'index.html');
|
||||||
|
const baseURL = process.env.AF_BASE_URL;
|
||||||
const setOrUpdateMetaTag = ($, selector, attribute, content) => {
|
const setOrUpdateMetaTag = ($, selector, attribute, content) => {
|
||||||
if ($(selector).length === 0) {
|
if ($(selector).length === 0) {
|
||||||
$('head').append(`<meta ${attribute}="${selector.match(/\[(.*?)\]/)[1]}" content="${content}">`);
|
$('head').append(`<meta ${attribute}="${selector.match(/\[(.*?)\]/)[1]}" content="${content}">`);
|
||||||
@ -86,10 +86,6 @@ const createServer = async (req) => {
|
|||||||
let metaData;
|
let metaData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isBeta = hostname.startsWith('beta');
|
|
||||||
const isTest = hostname.startsWith('test');
|
|
||||||
const defaultUrl = 'https://beta.appflowy.cloud';
|
|
||||||
const baseUrl = isBeta ? 'https://beta.appflowy.cloud' : isTest ? 'https://test.appflowy.cloud' : defaultUrl;
|
|
||||||
metaData = await fetchMetaData(`${baseUrl}/api/workspace/published/${namespace}/${publishName}`);
|
metaData = await fetchMetaData(`${baseUrl}/api/workspace/published/${namespace}/${publishName}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`Error fetching meta data: ${error}`);
|
logger.error(`Error fetching meta data: ${error}`);
|
||||||
@ -162,6 +158,7 @@ const start = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
logger.info(`Server is running on port 3000`);
|
logger.info(`Server is running on port 3000`);
|
||||||
|
logger.info(`Base URL: ${baseURL}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
process.exit(1);
|
process.exit(1);
|
@ -4,25 +4,15 @@ import React, { createContext, useEffect, useState } from 'react';
|
|||||||
import { AFService, AFServiceConfig } from '@/application/services/services.type';
|
import { AFService, AFServiceConfig } from '@/application/services/services.type';
|
||||||
import { getService } from '@/application/services';
|
import { getService } from '@/application/services';
|
||||||
|
|
||||||
const hostName = window.location.hostname;
|
const baseURL = import.meta.env.AF_BASE_URL;
|
||||||
const isProd = !hostName.includes('localhost');
|
const gotrueURL = import.meta.env.AF_GOTRUE_URL;
|
||||||
const isBeta = isProd && hostName.includes('beta');
|
const wsURL = import.meta.env.AF_WS_URL;
|
||||||
const isTest = isProd && hostName.includes('test');
|
|
||||||
const baseAPIHost = isProd
|
|
||||||
? isBeta
|
|
||||||
? 'beta.appflowy.cloud'
|
|
||||||
: isTest
|
|
||||||
? 'test.appflowy.cloud'
|
|
||||||
: 'beta.appflowy.cloud'
|
|
||||||
: 'test.appflowy.cloud';
|
|
||||||
const baseURL = `https://${baseAPIHost}`;
|
|
||||||
const gotrueURL = `${baseURL}/gotrue`;
|
|
||||||
|
|
||||||
const defaultConfig: AFServiceConfig = {
|
const defaultConfig: AFServiceConfig = {
|
||||||
cloudConfig: {
|
cloudConfig: {
|
||||||
baseURL,
|
baseURL,
|
||||||
gotrueURL,
|
gotrueURL,
|
||||||
wsURL: `wss://${baseAPIHost}/ws/v1`,
|
wsURL,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
AF_WS_URL=wss://test.appflowy.cloud/ws/v1
|
|
||||||
AF_BASE_URL=https://test.appflowy.cloud
|
|
||||||
AF_GOTRUE_URL=https://test.appflowy.cloud/gotrue
|
|
Loading…
Reference in New Issue
Block a user