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
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- build/test
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: 'Environment'
|
||||
required: true
|
||||
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:
|
||||
NODE_VERSION: "18.16.0"
|
||||
PNPM_VERSION: "8.5.0"
|
||||
@ -40,16 +53,12 @@ jobs:
|
||||
working-directory: frontend/appflowy_web_app
|
||||
run: |
|
||||
pnpm install
|
||||
- name: generate env file (Test)
|
||||
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test'
|
||||
- name: generate env file
|
||||
working-directory: frontend/appflowy_web_app
|
||||
run: |
|
||||
cp test.env .env
|
||||
- name: generate env file (Prod)
|
||||
if: github.event.inputs.environment == 'prod'
|
||||
working-directory: frontend/appflowy_web_app
|
||||
run: |
|
||||
cp beta.env .env
|
||||
echo "AF_BASE_URL=${{ github.event.inputs.api_base_url }}" >> .env
|
||||
echo "AF_GOTRUE_URL=${{ github.event.inputs.api_gotrue_url }}" >> .env
|
||||
echo "AF_WS_URL=${{ github.event.inputs.ws_url }}" >> .env
|
||||
- name: test and lint
|
||||
working-directory: frontend/appflowy_web_app
|
||||
run: |
|
||||
@ -61,22 +70,22 @@ jobs:
|
||||
- name: Archive build output
|
||||
working-directory: frontend/appflowy_web_app
|
||||
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)
|
||||
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test'
|
||||
if: github.event.inputs.environment == 'test'
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
with:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.WEB_TEST_SSH_PRIVATE_KEY }}
|
||||
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
|
||||
REMOTE_HOST: ${{ secrets.WEB_TEST_REMOTE_HOST }}
|
||||
REMOTE_USER: ${{ secrets.WEB_TEST_REMOTE_USER }}
|
||||
SCRIPT_AFTER: |
|
||||
cd appflowy-web-app
|
||||
chmod +x deploy.sh
|
||||
sh deploy.sh
|
||||
sh deploy.sh ${{ github.event.inputs.port }}
|
||||
- name: Deploy to EC2 (Prod)
|
||||
if: github.event.inputs.environment == 'prod'
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
@ -84,10 +93,10 @@ jobs:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.WEB_PROD_SSH_PRIVATE_KEY }}
|
||||
ARGS: "-rlgoDzvc -i"
|
||||
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_USER: ${{ secrets.WEB_PROD_REMOTE_USER }}
|
||||
SCRIPT_AFTER: |
|
||||
cd appflowy-web-app
|
||||
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
|
||||
```
|
||||
|
||||
- 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)
|
||||
|
||||
> **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
|
||||
```
|
||||
|
||||
#### 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
|
||||
|
||||
- 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
|
||||
|
||||
COPY . .
|
||||
COPY .. .
|
||||
|
||||
COPY supervisord.conf /app/supervisord.conf
|
||||
|
||||
@ -17,7 +17,7 @@ RUN addgroup --system nginx && \
|
||||
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
|
||||
|
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 indexPath = path.join(distDir, 'index.html');
|
||||
|
||||
const baseURL = process.env.AF_BASE_URL;
|
||||
const setOrUpdateMetaTag = ($, selector, attribute, content) => {
|
||||
if ($(selector).length === 0) {
|
||||
$('head').append(`<meta ${attribute}="${selector.match(/\[(.*?)\]/)[1]}" content="${content}">`);
|
||||
@ -86,10 +86,6 @@ const createServer = async (req) => {
|
||||
let metaData;
|
||||
|
||||
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}`);
|
||||
} catch (error) {
|
||||
logger.error(`Error fetching meta data: ${error}`);
|
||||
@ -162,6 +158,7 @@ const start = () => {
|
||||
},
|
||||
});
|
||||
logger.info(`Server is running on port 3000`);
|
||||
logger.info(`Base URL: ${baseURL}`);
|
||||
} catch (err) {
|
||||
logger.error(err);
|
||||
process.exit(1);
|
@ -4,25 +4,15 @@ import React, { createContext, useEffect, useState } from 'react';
|
||||
import { AFService, AFServiceConfig } from '@/application/services/services.type';
|
||||
import { getService } from '@/application/services';
|
||||
|
||||
const hostName = window.location.hostname;
|
||||
const isProd = !hostName.includes('localhost');
|
||||
const isBeta = isProd && hostName.includes('beta');
|
||||
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 baseURL = import.meta.env.AF_BASE_URL;
|
||||
const gotrueURL = import.meta.env.AF_GOTRUE_URL;
|
||||
const wsURL = import.meta.env.AF_WS_URL;
|
||||
|
||||
const defaultConfig: AFServiceConfig = {
|
||||
cloudConfig: {
|
||||
baseURL,
|
||||
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