Skip to content

Commit 41a5dd3

Browse files
authored
chore: modify deploy (#54)
* fix: the error width * chore: modified deploy process
1 parent 6431572 commit 41a5dd3

19 files changed

+597
-240
lines changed

.github/workflows/deploy.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- build/test
7+
workflow_dispatch:
8+
inputs:
9+
environment:
10+
description: 'Environment'
11+
required: true
12+
default: 'test'
13+
env:
14+
NODE_VERSION: "18.16.0"
15+
PNPM_VERSION: "8.5.0"
16+
17+
jobs:
18+
deploy:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: setup node
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
- name: setup pnpm
27+
uses: pnpm/action-setup@v2
28+
with:
29+
version: ${{ env.PNPM_VERSION }}
30+
- name: Node_modules cache
31+
uses: actions/cache@v2
32+
with:
33+
path: node_modules
34+
key: node-modules-${{ runner.os }}
35+
- name: install dependencies
36+
run: |
37+
pnpm install
38+
- name: generate env file (Test)
39+
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test'
40+
run: |
41+
echo "NODE_ENV=production" > .env
42+
echo "ENVIRONMENT=test" > .env
43+
echo "NEXT_PUBLIC_API_KEY=${{ secrets.TEXT_NEXT_PUBLIC_API_KEY }}" >> .env
44+
echo "NEXT_PUBLIC_GA_MEASUREMENT_ID=${{ secrets.TEXT_NEXT_PUBLIC_GA_MEASUREMENT_ID }}" >> .env
45+
- name: generate env file (Prod)
46+
if: github.event.inputs.environment == 'prod'
47+
run: |
48+
echo "NODE_ENV=production" > .env
49+
echo "ENVIRONMENT=production" > .env
50+
echo "NEXT_PUBLIC_API_KEY=${{ secrets.PROD_NEXT_PUBLIC_API_KEY }}" >> .env
51+
echo "NEXT_PUBLIC_GA_MEASUREMENT_ID=${{ secrets.PROD_NEXT_PUBLIC_GA_MEASUREMENT_ID }}" >> .env
52+
- name: build
53+
run: |
54+
pnpm run build
55+
- name: Archive build output
56+
run: |
57+
tar -czf build-output.tar.gz .next .env public Dockerfile supervisord.conf next.config.js env.js node_modules package.json
58+
59+
- name: Deploy to EC2 (Test)
60+
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test'
61+
uses: easingthemes/ssh-deploy@main
62+
with:
63+
SSH_PRIVATE_KEY: ${{ secrets.TEST_SSH_PRIVATE_KEY }}
64+
ARGS: "-rlgoDzvc -i"
65+
SOURCE: build-output.tar.gz deploy.sh
66+
TARGET: /home/${{ secrets.TEST_SSH_USER }}/appflowy.io
67+
REMOTE_HOST: ${{ secrets.TEST_SSH_HOST }}
68+
REMOTE_USER: ${{ secrets.TEST_SSH_USER }}
69+
SCRIPT_AFTER: |
70+
cd appflowy.io
71+
chmod +x deploy.sh
72+
sh deploy.sh
73+
- name: Deploy to EC2 (Prod)
74+
if: github.event.inputs.environment == 'prod'
75+
uses: easingthemes/ssh-deploy@main
76+
with:
77+
SSH_PRIVATE_KEY: ${{ secrets.PROD_SSH_PRIVATE_KEY }}
78+
ARGS: "-rlgoDzvc -i"
79+
TARGET: /home/${{ secrets.PROD_SSH_USER }}/appflowy.io
80+
SOURCE: build-output.tar.gz deploy.sh
81+
REMOTE_HOST: ${{ secrets.PROD_SSH_HOST }}
82+
REMOTE_USER: ${{ secrets.PROD_SSH_USER }}
83+
SCRIPT_AFTER: |
84+
cd appflowy.io
85+
chmod +x deploy.sh
86+
sh deploy.sh

.github/workflows/deploy_dev.yml

-38
This file was deleted.

.github/workflows/deploy_prod.yml

-37
This file was deleted.

Dockerfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Use the official Node.js image as a base image
2+
FROM node:18
3+
4+
RUN apt-get update && apt-get install -y supervisor
5+
6+
# Create and change to the app directory
7+
WORKDIR /app
8+
9+
COPY . .
10+
11+
COPY supervisord.conf /app/supervisord.conf
12+
13+
RUN chmod +x /app/supervisord.conf
14+
15+
EXPOSE 3000
16+
17+
CMD ["supervisord", "-c", "/app/supervisord.conf"]

app/invitation/expired/page.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ import ExpireDescription from '@/components/invitation/expired-description';
44
import InviteOwner from '@/components/invitation/invite-owner';
55
import InviteWorkspace from '@/components/invitation/invite-workspace';
66
import '@/styles/invitation.scss';
7-
import { Poppins } from 'next/font/google';
87
import Image from 'next/image';
98
import Link from 'next/link';
109
import NextTopLoader from 'nextjs-toploader';
1110

12-
const poppins = Poppins({ subsets: ['latin'], weight: ['400', '500', '600', '700'] });
13-
1411
function Page() {
1512
return (
16-
<div className={`expired-page ${poppins.className}`}>
13+
<div className={`expired-page`}>
1714
<NextTopLoader showSpinner={false} color={'#9327FF'} />
1815
<div className={'header'}>
1916
<div className={'logo-wrapper'}>

app/layout.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import './globals.scss';
22
import type { Metadata } from 'next';
3-
import { Inter } from 'next/font/google';
43
import Favicon from '../public/favicon.ico';
54
import OpenGraph from '../public/images/og-image.png';
65
import App from '@/components/layout/app';
76
import { getModeForServer } from '@/lib/get-theme';
87
import { getGitData } from '@/lib/get-git';
98
import { getUAFromServer } from '@/lib/get-os';
109

11-
const inter = Inter({ subsets: ['latin'] });
12-
1310
export const metadata: Metadata = {
1411
title: 'AppFlowy.IO',
1512
description: 'AppFlowy is an AI collaborative workspace where you achieve more without losing control of your data',
@@ -44,7 +41,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
4441

4542
return (
4643
<html lang='en' className={mode}>
47-
<body id={'body'} className={inter.className}>
44+
<body id={'body'}>
4845
<App ua={ua} gitData={gitData} mode={mode}>
4946
{children}
5047
</App>

aws-upload.js

-66
This file was deleted.

components/shared/over-title.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ import darkIcon1 from '@/assets/images/download/dark/icon-1.png';
77
import darkIcon2 from '@/assets/images/download/dark/icon-2.png';
88
import darkIcon3 from '@/assets/images/download/dark/icon-3.png';
99
import { downloadPageConfig } from '@/lib/config/pages';
10-
import { Manrope } from 'next/font/google';
1110
import { useDarkContext } from '@/lib/hooks/use-dark-context';
1211
import { motion, useMotionValue, useSpring } from 'framer-motion';
1312

14-
const manrope = Manrope({ subsets: ['latin'] });
15-
1613
function OverTitle({ title }: { title: string }) {
1714
const dark = useDarkContext();
1815
const ref = useRef<HTMLDivElement>(null);
@@ -56,7 +53,7 @@ function OverTitle({ title }: { title: string }) {
5653
const currentScrollTop = document.documentElement.scrollTop;
5754

5855
const scrollDistance = -(currentScrollTop - diff) * delta;
59-
56+
6057
if (Math.abs(scrollDistance) > scrollWidth / 2) {
6158
return;
6259
}
@@ -99,9 +96,10 @@ function OverTitle({ title }: { title: string }) {
9996
<motion.div
10097
style={{
10198
x,
99+
fontFamily: 'Manrope',
102100
}}
103101
ref={ref}
104-
className={`translate-z-0 over-title transform ${manrope.className}`}
102+
className={`translate-z-0 over-title transform`}
105103
>
106104
<div className={`title-text`}>{title}</div>
107105
<div className={'icons'}>

deploy.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
rm -rf .next .env public Dockerfile supervisord.conf package.json next.config.js env.js node_modules
4+
5+
tar -xzf build-output.tar.gz
6+
7+
rm build-output.tar.gz
8+
9+
docker system prune -f
10+
11+
docker build -t official-website-app .
12+
13+
docker rm -f official-website-app || true
14+
15+
docker run -d --env-file .env -p 30013:3000 --restart always --name official-website-app official-website-app

ecosystem.config.js

-11
This file was deleted.

next.config.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
const path = require('path');
2+
3+
try {
4+
require('./env.js');
5+
} catch (e) {
6+
console.log('Error loading .env file');
7+
}
8+
29
const isProd = process.env.NODE_ENV === 'production';
310
const environment = process.env.ENVIRONMENT || 'development';
4-
require('./env');
11+
12+
let assetPrefix = undefined;
13+
if (isProd) {
14+
if (environment === 'production') {
15+
assetPrefix = 'https://appflowy.io';
16+
} else if (environment === 'test') {
17+
assetPrefix = 'https://test.appflowy.io';
18+
}
19+
}
520
const securityHeaders = [
621
{
722
key: 'X-Frame-Options',
@@ -43,12 +58,13 @@ const rewrites = () => {
4358
/** @type {import('next').NextConfig} */
4459
const nextConfig = {
4560
reactStrictMode: false,
61+
4662
sassOptions: {
4763
includePaths: [path.join(__dirname, 'styles')],
4864
},
4965

5066
// Use the CDN in production and localhost for development.
51-
assetPrefix: isProd ? `https://d3uafhn8yrvdfn.cloudfront.net/website/${environment}` : undefined,
67+
assetPrefix,
5268
rewrites,
5369
images: {
5470
remotePatterns: [

0 commit comments

Comments
 (0)