Skip to content

Instantly share code, notes, and snippets.

@mikolaj6r
Last active August 7, 2023 18:53
Show Gist options
  • Save mikolaj6r/9bb992a2cbfe9d1403cccc38bae68483 to your computer and use it in GitHub Desktop.
Save mikolaj6r/9bb992a2cbfe9d1403cccc38bae68483 to your computer and use it in GitHub Desktop.
Assumptions: you are using node v10 (https://wiki.mydevil.net/Node.js)
On server:
0) create site of node type ( remember to use production or development env), create mongodb db, create 2 private git repos and assign users to them
1) go into domain folder
2) rm -rf public_nodejs
4) mkdir frontend
5) mkdir backend
6) ln -s backend public_nodejs
7) Now add hook on server for frontend and backend ( two repos )
7.1) Strapi (backend)
cd ~/repo/git/priv/REPO_NAME/hooks
Customize the below script and paste in to terminal.
echo '#!/bin/sh
unset GIT_INDEX_FILE
export DOMAIN= #domain
export LOGIN= #login
export VISIBILITY= #visibility
export REPONAME= #reponame
export GIT_WORK_TREE="/usr/home/$LOGIN/domains/$DOMAIN/backend"
export GIT_DIR="/usr/home/$LOGIN/repo/git/$VISIBILITY/$REPONAME/"
/usr/local/bin/git checkout -f
cd /usr/home/$LOGIN/domains/$DOMAIN/backend && ~/bin/npm install
devil www restart $DOMAIN' >post-receive
chmod +x post-receive*
7.2) Gatsby (frontend)
cd ~/repo/git/priv/REPO_NAME/hooks
Customize the below script and paste in to terminal.
echo '#!/bin/sh
unset GIT_INDEX_FILE
export DOMAIN= #domain
export LOGIN= #login
export VISIBILITY= #visibility
export REPONAME= #reponame
export GIT_WORK_TREE="/usr/home/$LOGIN/domains/$DOMAIN/frontend"
export GIT_DIR="/usr/home/$LOGIN/repo/git/$VISIBILITY/$REPONAME/"
/usr/local/bin/git checkout -f
cd /usr/home/$LOGIN/domains/$DOMAIN/frontend && ~/bin/npm install && ~/bin/npm run build
cd ../ && cp -rf frontend/public/* backend/public
cd $CURR
' >post-receive
chmod +x post-receive*
On local:
1) mkdir domain;
2) cd domain
3) Set up Backend (Strapi)
3.1 Using GIT:
git clone git@github.com:mikolaj6r/strapi-mydevil-app.git
mv strapi-mydevil-app backend
edit backend/config/environments/development/database.json and similar in production env.
Inside JSON change: DB_HOST, DB_PASS, DB_NAME
cd backend and run "npm install"
You can test installation by typing "strapi start" or "npm run start"
Now add commit and push to origin.
git add .
git commit -m "set up db"
git remote add boilerplate git@github.com:mikolaj6r/strapi-mydevil-starter.git
git remote set-url origin https://repo37.mydevil.net/git/priv/mikolaj6r/strapi-test/
git push origin master
3.2 on your own:
npx -p strapi@alpha strapi new backend
Custom settings ( database, NOT quick start )
Choose your main database: MongoDB
? Database name: DB_NAME
? Host: DB_SERVER
? +srv connection: false
? Port (It will be ignored if you enable +srv): 27017
? Username: DB_NAME
? Password: DB_PASSWORD
? Authentication database (Maybe "admin" or blank): DB_NAME
edit backend/config/environments/production/database.json.
Inside JSON change: DB_HOST, DB_PASS, DB_NAME (you can copy from backend/config/env/development/database)
You can test installation by typing "strapi start" or "npm run start"
git init
git add .
git commit -m "initial commit"
git remote add boilerplate git@github.com:mikolaj6r/gatsby-mydevil-starter.git
git remote add origin https://repo37.mydevil.net/git/priv/mikolaj6r/gatsby-test
git push origin master
4) Set up Frontend (Gatsby)
4.1 Using GIT
cd domain
git clone git@github.com:mikolaj6r/gatsby-mydevil-starter.git
mv gatsby-mydevil-starter frontend
cd fronted
git remote add boilerplate git@github.com:mikolaj6r/gatsby-mydevil-starter.git
git remote set-url origin https://repo37.mydevil.net/git/priv/mikolaj6r/gatsby-test
git push origin master
4.2 On your own:
cd domain
npx gatsby new frontend https://github.com/gatsbyjs/gatsby-starter-default
If you run into errors type:
cd frontend && rm -fr node_modules && yarn cache clean && npm install
Test using "npm start"
git init
git add .
git commit -m "initial commit"
git remote add boilerplate git@github.com:mikolaj6r/gatsby-mydevil-starter.git
git remote add origin https://repo37.mydevil.net/git/priv/mikolaj6r/gatsby-test
git push origin master
That's all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment