Skip to content

Commit

Permalink
Add artifacts for standalone execution
Browse files Browse the repository at this point in the history
  • Loading branch information
DJDavid98 committed Jan 6, 2022
1 parent 9702cb0 commit 610a93e
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn build
npm run build
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lodash": "^4.17.20",
"moment": "^2.29.1",
"moment-timezone": "^0.5.33",
"next": "^12.0.0",
"next": "^12.0.5",
"next-compose-plugins": "^2.2.1",
"next-i18next": "^8.5.5",
"next-seo": "^4.17.0",
Expand Down
12 changes: 12 additions & 0 deletions pm2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"apps": [
{
"name": "HammerTime",
"script": "npm start",
"log_date_format": "YYYY-MM-DD HH:mm:ss Z",
"env": {
"PORT": "6901"
}
}
]
}
28 changes: 28 additions & 0 deletions setup/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
server {
listen 80;
listen 443 ssl http2;
listen [::]:80;
listen [::]:443 ssl http2;
server_name domain.tld;
log_not_found off;
access_log off;

if ($scheme != 'https'){
return 302 https://$host$request_uri;
}

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options "sameorigin" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;

gzip on;
gzip_proxied any;
gzip_comp_level 9;
gzip_types text/plain text/css text/javascript application/json image/svg+xml;
gzip_vary on;

location / {
proxy_pass http://localhost:6901;
}
}
45 changes: 45 additions & 0 deletions setup/post-receive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
echo "##### post-receive hook #####"
read oldrev newrev refname
echo "Push triggered update to revision $newrev ($refname)"

RUN_FOR_REF="refs/heads/main"
if [[ "$refname" == "$RUN_FOR_REF" ]]; then
GIT="env -i git"
CMD_CD="cd $(readlink -nf "$PWD/..")"
CMD_FETCH="$GIT fetch"
CMD_YARN="npm"
CMD_BUILD="nice npm run build"
CMD_RESTART="pm2 reload pm2.json"

echo "$ $CMD_CD"
eval ${CMD_CD}
echo "$ $CMD_FETCH"
eval ${CMD_FETCH}

if $GIT diff --name-only $oldrev $newrev | grep "^package-lock.json"; then
echo "$ $CMD_YARN"
eval $CMD_YARN
else
echo "# Skipping npm install, lockfile not modified"
fi

if $GIT diff --name-only $oldrev $newrev | grep "^\(src\|public\|package-lock.json\)/"; then
echo "$ $CMD_BUILD"
if eval $CMD_BUILD; then
echo "Build successful"
else
echo "Build failed"
exit 1
fi
else
echo "# Skipping build, no changes in src or public folders"
fi

echo "$ $CMD_RESTART"
eval $CMD_RESTART
else
echo "Ref does not match $RUN_FOR_REF, exiting."
fi

echo "##### end post-receive hook #####"

0 comments on commit 610a93e

Please sign in to comment.