forked from AppFlowy-IO/AppFlowy-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
619 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- build/test | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
description: 'Environment' | ||
required: true | ||
default: 'test' | ||
env: | ||
NODE_VERSION: "18.16.0" | ||
PNPM_VERSION: "8.5.0" | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: setup node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
- name: setup pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: ${{ env.PNPM_VERSION }} | ||
- name: Node_modules cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: node_modules | ||
key: node-modules-${{ runner.os }} | ||
- name: install dependencies | ||
run: | | ||
pnpm install | ||
- name: generate env file (Test) | ||
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test' | ||
run: | | ||
echo "ENVIRONMENT=test" > .env | ||
echo "NEXT_PUBLIC_API_KEY=${{ secrets.TEXT_NEXT_PUBLIC_API_KEY }}" >> .env | ||
echo "NEXT_PUBLIC_GA_MEASUREMENT_ID=${{ secrets.TEXT_NEXT_PUBLIC_GA_MEASUREMENT_ID }}" >> .env | ||
- name: generate env file (Prod) | ||
if: github.event.inputs.environment == 'prod' | ||
run: | | ||
echo "ENVIRONMENT=production" > .env | ||
echo "NEXT_PUBLIC_API_KEY=${{ secrets.PROD_NEXT_PUBLIC_API_KEY }}" >> .env | ||
echo "NEXT_PUBLIC_GA_MEASUREMENT_ID=${{ secrets.PROD_NEXT_PUBLIC_GA_MEASUREMENT_ID }}" >> .env | ||
- name: build | ||
run: | | ||
pnpm run build | ||
- name: Archive build output | ||
run: | | ||
tar -czf build-output.tar.gz .next .env public Dockerfile start.sh next.config.js env.js nginx.conf | ||
- name: Deploy to EC2 (Test) | ||
if: github.event.inputs.environment == 'test' || github.ref == 'refs/heads/build/test' | ||
uses: easingthemes/ssh-deploy@main | ||
with: | ||
SSH_PRIVATE_KEY: ${{ secrets.TEST_SSH_PRIVATE_KEY }} | ||
ARGS: "-rlgoDzvc -i" | ||
SOURCE: build-output.tar.gz deploy.sh | ||
TARGET: /home/${{ secrets.TEST_SSH_USER }}/appflowy.io | ||
REMOTE_HOST: ${{ secrets.TEST_SSH_HOST }} | ||
REMOTE_USER: ${{ secrets.TEST_SSH_USER }} | ||
SCRIPT_AFTER: | | ||
cd appflowy.io | ||
chmod +x deploy.sh | ||
sh deploy.sh | ||
- name: Deploy to EC2 (Prod) | ||
if: github.event.inputs.environment == 'prod' | ||
uses: easingthemes/ssh-deploy@main | ||
with: | ||
SSH_PRIVATE_KEY: ${{ secrets.PROD_SSH_PRIVATE_KEY }} | ||
ARGS: "-rlgoDzvc -i" | ||
TARGET: /home/${{ secrets.PROD_SSH_USER }}/appflowy.io | ||
SOURCE: build-output.tar.gz deploy.sh | ||
REMOTE_HOST: ${{ secrets.PROD_SSH_HOST }} | ||
REMOTE_USER: ${{ secrets.PROD_SSH_USER }} | ||
SCRIPT_AFTER: | | ||
cd appflowy.io | ||
chmod +x deploy.sh | ||
sh deploy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Use the official Node.js image as a base image | ||
FROM node:18 | ||
# Create and change to the app directory | ||
WORKDIR /app | ||
|
||
RUN npm install -g [email protected] | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y nginx | ||
|
||
COPY . . | ||
|
||
RUN addgroup --system nginx && \ | ||
adduser --system --no-create-home --disabled-login --ingroup nginx nginx | ||
|
||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
COPY nginx.conf /etc/nginx/nginx.conf | ||
COPY .next/ /usr/share/nginx/html/.next/ | ||
COPY public/ /usr/share/nginx/html/public/ | ||
|
||
# Expose the port the app runs on | ||
COPY start.sh /app/start.sh | ||
COPY next.config.js /app/next.config.js | ||
COPY .env /app/.env | ||
COPY env.js /app/env.js | ||
|
||
RUN chmod +x /app/start.sh | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["/app/start.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
rm -rf .next .env public start.sh Dockerfile next.config.js env.js nginx.conf | ||
|
||
tar -xzf build-output.tar.gz | ||
|
||
docker system prune -f | ||
|
||
docker rm -f official-website-app || true | ||
|
||
# | ||
#docker build -t official-website-app . | ||
# | ||
#docker run -d --env-file .env -p 3001:80 official-website-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# nginx.conf | ||
user nginx; | ||
worker_processes auto; | ||
|
||
error_log /var/log/nginx/error.log notice; | ||
pid /var/run/nginx.pid; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_timeout 65; | ||
|
||
gzip on; | ||
|
||
gzip_static on; | ||
|
||
gzip_http_version 1.0; | ||
|
||
gzip_comp_level 5; | ||
|
||
gzip_vary on; | ||
|
||
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/wasm; | ||
|
||
# Existing server block for HTTP | ||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
location / { | ||
proxy_pass http://localhost:3000; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection 'upgrade'; | ||
proxy_set_header Host $host; | ||
proxy_cache_bypass $http_upgrade; | ||
} | ||
|
||
location /_next/static/ { | ||
alias /usr/share/nginx/html/.next/static/; | ||
expires 30d; | ||
access_log off; | ||
} | ||
|
||
location /html/ { | ||
alias /usr/share/nginx/html/public/html/; | ||
expires 30d; | ||
access_log off; | ||
} | ||
|
||
location /images/ { | ||
alias /usr/share/nginx/html/public/images/; | ||
expires 30d; | ||
access_log off; | ||
} | ||
location /favicon.ico { | ||
alias /usr/share/nginx/html/public/favicon.ico; | ||
expires 30d; | ||
access_log off; | ||
} | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
# Start the nginx server | ||
service nginx start | ||
|
||
# Start the frontend server | ||
next start | ||
|
||
tail -f /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.