Skip to content

Commit 97bc072

Browse files
author
Touqeer Ahmad
committed
NextJS support added
1 parent f077678 commit 97bc072

File tree

14 files changed

+213
-3
lines changed

14 files changed

+213
-3
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ The following stacks are currently supported
3939
- Django
4040
- React JS
4141
- Node JS
42+
- Next JS
4243
- PHP
4344
- Static HTML
4445

@@ -103,6 +104,9 @@ sh install.sh python /path/to/django/project
103104
# or for a reactjs project
104105
sh install.sh reactjs /path/to/reactjs/project
105106

107+
# or for a nextjs project
108+
sh install.sh nextjs /path/to/nextjs/project
109+
106110
# or for a node project
107111
sh install.sh node /path/to/node/project
108112

@@ -130,6 +134,9 @@ deploy --install python /path/to/django/project
130134
# or for a reactjs project
131135
deploy --install reactjs /path/to/reactjs/project
132136

137+
# or for a nextjs project
138+
deploy --install nextjs /path/to/nextjs/project
139+
133140
# or for a node project
134141
deploy --install node /path/to/node/project
135142

@@ -188,7 +195,7 @@ It can also use the commented out optional files that are listed, but will work
188195
All projects must have the following vars defined (in app-config.sh or config.sh) so that the relevant steps are executed.
189196

190197
```bash
191-
# The project type. Currently supported options are: java, rails, python, node, and reactjs
198+
# The project type. Currently supported options are: java, rails, python, node, reactjs and nextjs
192199
TYPE=rails
193200
# The name that will be used to label the app that is being deployed, commonly the hostname where the service is made available is used
194201
SERVICE_NAME=service.com
@@ -294,6 +301,8 @@ sh tests/java.sh
294301
sh tests/rails.sh
295302
# Test React JS deployment
296303
sh tests/reactjs.sh
304+
# Test Next JS deployment
305+
sh tests/nextjs.sh
297306
# Test Django deployment
298307
sh tests/django.sh
299308
# Test Static HTML and PHP website deployment
@@ -361,6 +370,8 @@ Currently allowed values:
361370

362371
- `reactjs`
363372

373+
- `nextjs`
374+
364375
- `html` - for static HTML sites or simple PHP sites
365376

366377
### `BUILD`
@@ -371,7 +382,7 @@ Currently allowed values:
371382

372383
- `mvnw` - for java projects
373384

374-
- `npm` - for reactjs projects
385+
- `npm` - for reactjs and nextjs projects
375386

376387
### `FORMAT`
377388

@@ -389,6 +400,8 @@ Currently allowed values:
389400

390401
- `reactjs` - for reactjs projects
391402

403+
- `nextjs` - for nextjs projects
404+
392405
- `static` - for static HTML sites or simple PHP sites
393406

394407
### `REPO`

deploy-scripts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ show_ds_usage() {
1616

1717
show_installer_usage() {
1818
show_version
19-
printf "\nUsage:\n\tdeploy-scripts.sh --install [project type] [project directory] [options]\n\nThe values for [project type] can be\n\tjava\n\trails\n\tpython\n\treactjs\n\thtml\n\tnode\n"
19+
printf "\nUsage:\n\tdeploy-scripts.sh --install [project type] [project directory] [options]\n\nThe values for [project type] can be\n\tjava\n\trails\n\tpython\n\treactjs\n\tnextjs\n\thtml\n\tnode\n"
2020
exit 1
2121
}
2222

installer/upgrade.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ elif [ "$BUILD" = "python-django" ]; then
4242
elif [ "$BUILD" = "reactjs" ]; then
4343
TYPE="reactjs"
4444
BUILD="npm"
45+
elif [ "$BUILD" = "nextjs" ]; then
46+
TYPE="nextjs"
47+
BUILD="npm"
4548
elif [ "$BUILD" = "rails" ]; then
4649
TYPE="rails"
4750
BUILD=""

projects/nextjs/build/npm.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ds_build() {
2+
if [ "$1" = "" ] || [ "$2" = "" ]; then
3+
error "build: npm: Too few arguments given"
4+
fi
5+
if [ ! -d "$2" ]; then
6+
error "build: npm: No package directory available to place warfile"
7+
fi
8+
cd "$1"
9+
10+
ENV_JS_PATH="$1/../repo/$DS_DIR/environments/$PROJECT_ENVIRONMENT/.env"
11+
if [ ! -f "$ENV_JS_PATH" ]; then
12+
if [ "$NEXTJS_ENVJS_PATH" != "" ]; then
13+
CHECK_ABS_PATH=$(echo $NEXTJS_ENVJS_PATH | cut -c -1)
14+
if [ "$CHECK_ABS_PATH" = "/" ]; then
15+
ENV_JS_PATH="$NEXTJS_ENVJS_PATH"
16+
else
17+
ENV_JS_PATH="$1/../repo/$DS_DIR/$NEXTJS_ENVJS_PATH"
18+
fi
19+
fi
20+
fi
21+
if [ ! -f "$ENV_JS_PATH" ]; then
22+
warning "No .env found at $ENV_JS_PATH. Building without it"
23+
else
24+
ln -s "$ENV_JS_PATH" .env
25+
fi
26+
27+
if [ "$NPM_PREFIX" != "" ]; then
28+
mkdir -p $NPM_PREFIX && ln -sf $NPM_PREFIX node_modules && npm install
29+
else
30+
npm install
31+
fi
32+
npx next build
33+
npx next export
34+
if [ -d "./out" ]; then
35+
cp -r ./out/* "$2/"
36+
else
37+
error "NPM output directory not found under either out/"
38+
fi
39+
}

projects/nextjs/format/nextjs.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ds_format() {
2+
if [ "$1" = "" ]; then
3+
error "format: nextjs: Too few arguments given"
4+
fi
5+
6+
cd "$1"
7+
8+
info "Preparing deployment files for packaging ... "
9+
git --work-tree=./ --git-dir=../repo/.git checkout -f 2>&1 | indent
10+
success 'done'
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ds_install () {
2+
if [ "$1" = "" ]; then
3+
error "installer: nextjs: Project directory not supplied"
4+
fi
5+
6+
ds_create_dir_structure "$1" "$DS_DIR" "nextjs"
7+
infof "Adding nextjs vars to app-config.sh ... "
8+
printf "BUILD=npm\n" >> "$1/$DS_DIR/app-config.sh"
9+
printf "LINKED_FILES=\"src/_config/env.js\"\n" >> "$1/$DS_DIR/app-config.sh"
10+
printf "LINKED_DIRS=\"logs\"\n" >> "$1/$DS_DIR/app-config.sh"
11+
success "done"
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
SCRIPT_PATH=$(dirname $(readlink -f $0))
6+
. $SCRIPT_PATH/post-receive-utils.sh
7+
8+
deploy
9+
10+
if [ "$FORMAT" = "nextjs" ] && [ "$BUILD" = "" ]; then
11+
title 'deploy - build'
12+
cd $DEPLOY_DIR/current
13+
npm install
14+
npx next build
15+
npx next export
16+
fi
17+
18+
post_startup
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
TYPE=nextjs
2+
BUILD=npm
3+
REPO=git@github.com:loanstreet/app-name.git
4+
5+
DEPLOYMENT_SERVER=dev-partners.loanstreet.com.my
6+
DEPLOYMENT_SSH_USER=deploy
7+
SERVICE_NAME=app-name
8+
LINKED_FILES="src/_config/env.js"
9+
LINKED_DIRS="logs"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
server {
2+
listen 80 ;
3+
server_name xc-test.finology.com.my;
4+
5+
gzip on;
6+
gzip_http_version 1.0;
7+
gzip_disable "msie6";
8+
gzip_vary on;
9+
gzip_min_length 1100;
10+
gzip_buffers 64 8k;
11+
gzip_comp_level 3;
12+
gzip_proxied any;
13+
gzip_types text/css text/xml application/x-javascript application/atom+xml text/mathml text/plain text/vnd.sun.j2me.app-descriptor text/vnd.wap.wml text/x-component;
14+
15+
root /home/deploy/sites/xpresscover-portal/staging/current/build;
16+
access_log /home/deploy/sites/xpresscover-portal/staging/current/logs/nginx.access.log;
17+
error_log /home/deploy/sites/xpresscover-portal/staging/current/logs/nginx.error.log info;
18+
19+
error_page 500 502 503 504 /500.html;
20+
client_max_body_size 25M;
21+
keepalive_timeout 10;
22+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PROJECT_ENVIRONMENT=default
2+
GIT_BRANCH=default

0 commit comments

Comments
 (0)