Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): deployment for frontend #458

Merged
merged 28 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
96ed5f3
moved existing scripts into scripts folder
ulfgebhardt Apr 8, 2024
f8f5900
start frotnend script
ulfgebhardt Apr 8, 2024
34c1a27
update deploy script (paths)
ulfgebhardt Apr 8, 2024
bd00553
define ports properly, adjust port in nginx
ulfgebhardt Apr 8, 2024
aea592a
configure host to serve /app/
ulfgebhardt Apr 8, 2024
a2dd595
configure base url for frontend
ulfgebhardt Apr 8, 2024
77b9e46
remove quotations
ulfgebhardt Apr 8, 2024
3810b36
baseServer config
ulfgebhardt Apr 8, 2024
b9ff7dc
staticly define base
ulfgebhardt Apr 8, 2024
f3b659f
adjuadjust baseAssests url
ulfgebhardt Apr 8, 2024
5fb6387
do not define base either
ulfgebhardt Apr 8, 2024
1dbfc4c
work with base server
ulfgebhardt Apr 8, 2024
baa8c18
removeutilize nginx config for subpath
ulfgebhardt Apr 8, 2024
7041ba5
use base
ulfgebhardt Apr 8, 2024
edb46de
base assets aswell
ulfgebhardt Apr 8, 2024
1a05c2f
app assets without base
ulfgebhardt Apr 8, 2024
5ce19b9
more tests with bases
ulfgebhardt Apr 8, 2024
426d8ab
no vike base
ulfgebhardt Apr 8, 2024
a1d9cb2
use absolute url
ulfgebhardt Apr 8, 2024
b3b02f5
ngninx config
ulfgebhardt Apr 8, 2024
1d81a1d
use all bases
ulfgebhardt Apr 8, 2024
97bf245
use subdomain for frontend
ulfgebhardt Apr 9, 2024
3230a9b
remove guard
ulfgebhardt Apr 9, 2024
37b394a
fix guard
ulfgebhardt Apr 9, 2024
775fe8d
put guard back in place
ulfgebhardt Apr 9, 2024
ac9c36e
Merge branch 'master' into frontend-deploy
ulfgebhardt Apr 9, 2024
2030f67
update readme for deployment
ulfgebhardt Apr 9, 2024
5a88a43
Merge branch 'master' into frontend-deploy
ulfgebhardt Apr 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ Configure nginx:
cp -f deployment/nginx/default.conf /etc/nginx/http.d/default.conf
# adjust the nginx config accordingly
vi /etc/nginx/http.d/default.conf
# frontend nginx config
cp deployment/nginx/frontend.conf /etc/nginx/http.d/frontend.conf
# adjust the frontend nginx config accordingly
vi /etc/nginx/http.d/frontend.conf
# note: replace log paths according to your installation directory
service nginx restart
```
Expand Down
16 changes: 10 additions & 6 deletions deployment/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,20 @@ exec 3>&1 1>>${LOG_FILE} 2>&1 2>>${LOG_ERROR_FILE}
export NODE_ENV=production

# Backend & Database Migration
$SCRIPT_DIR/build.backend.sh
$SCRIPT_DIR/migrate.database.sh
$SCRIPT_DIR/start.backend.sh
$SCRIPT_DIR/scripts/build.backend.sh
$SCRIPT_DIR/scripts/migrate.database.sh
$SCRIPT_DIR/scripts/start.backend.sh

# Frontend
$SCRIPT_DIR/scripts/build.frontend.sh
$SCRIPT_DIR/scripts/start.frontend.sh

# Presenter
$SCRIPT_DIR/build.presenter.sh
$SCRIPT_DIR/start.presenter.sh
$SCRIPT_DIR/scripts/build.presenter.sh
$SCRIPT_DIR/scripts/start.presenter.sh

# Docs
$SCRIPT_DIR/build.docs.sh
$SCRIPT_DIR/scripts/build.docs.sh

# restore node env
NODE_ENV=$BACKUP_NODE_ENV
Expand Down
2 changes: 1 addition & 1 deletion deployment/nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ server {
proxy_buffers 4 512k;
proxy_buffer_size 256k;

proxy_pass http://127.0.0.1:3000/;
proxy_pass http://127.0.0.1:3001/;
proxy_redirect off;

access_log /var/www/localhost/htdocs/dreammall.earth/log/nginx.access.presenter.log combined;
Expand Down
21 changes: 21 additions & 0 deletions deployment/nginx/frontend.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
server {
listen 8080 default_server;
listen [::]:8080 default_server;

location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_buffers 4 512k;
proxy_buffer_size 256k;

proxy_pass http://127.0.0.1:3000/;
proxy_redirect off;

access_log /var/www/localhost/htdocs/dreammall.earth/log/nginx.access.frontend.log combined;
error_log /var/www/localhost/htdocs/dreammall.earth/log/nginx.error.frontend.log warn;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Find current directory & configure paths
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
PROJECT_ROOT=$SCRIPT_DIR/../backend
PROJECT_ROOT=$SCRIPT_DIR/../../backend
BUILD_DIR=$PROJECT_ROOT/build

# Build the project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Find current directory & configure paths
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
PROJECT_ROOT=$SCRIPT_DIR/..
PROJECT_ROOT=$SCRIPT_DIR/../..
BUILD_DIR=$PROJECT_ROOT/build/docs

# Build the project
Expand Down
13 changes: 13 additions & 0 deletions deployment/scripts/build.frontend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# Find current directory & configure paths
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
PROJECT_ROOT=$SCRIPT_DIR/../../frontend
BUILD_DIR=$PROJECT_ROOT/build

# Build the project
cd $PROJECT_ROOT
rm -R $BUILD_DIR
npm install --include=dev
npm run build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Find current directory & configure paths
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
PROJECT_ROOT=$SCRIPT_DIR/../presenter
PROJECT_ROOT=$SCRIPT_DIR/../../presenter
BUILD_DIR=$PROJECT_ROOT/build

# Build the project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Find current directory & configure paths
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
PROJECT_ROOT=$SCRIPT_DIR/../backend
PROJECT_ROOT=$SCRIPT_DIR/../../backend

# Build the project
cd $PROJECT_ROOT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

# Find current directory & configure paths
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)/../backend
LOG_FILE=$SCRIPT_DIR/../log/$(date +"%Y-%m-%d_%T")_pm2.backend.log
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
PROJECT_ROOT=$SCRIPT_DIR/../../backend
LOG_FILE=$SCRIPT_DIR/../../log/$(date +"%Y-%m-%d_%T")_pm2.backend.log

cd $SCRIPT_DIR
cd $PROJECT_ROOT
NODE_ENV=production TZ=UTC TS_NODE_BASEURL=./build pm2 start --name backend "node -r tsconfig-paths/register build/src/index.js" -l $LOG_FILE --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS'
pm2 save
12 changes: 12 additions & 0 deletions deployment/scripts/start.frontend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

# Find current directory & configure paths
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
PROJECT_ROOT=$SCRIPT_DIR/../../frontend
LOG_FILE=$SCRIPT_DIR/../../log/$(date +"%Y-%m-%d_%T")_pm2.frontend.log

cd $PROJECT_ROOT
export PORT=3000
pm2 start --name frontend "build/index.cjs" -l $LOG_FILE --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS'
pm2 save
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

# Find current directory & configure paths
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)/../presenter
LOG_FILE=$SCRIPT_DIR/../log/$(date +"%Y-%m-%d_%T")_pm2.presenter.log
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
PROJECT_ROOT=$SCRIPT_DIR/../../presenter
LOG_FILE=$SCRIPT_DIR/../../log/$(date +"%Y-%m-%d_%T")_pm2.presenter.log

cd $SCRIPT_DIR
cd $PROJECT_ROOT
export PORT=3001
pm2 start --name presenter "build/index.cjs" -l $LOG_FILE --log-date-format 'YYYY-MM-DD HH:mm:ss.SSS'
pm2 save