This file contains hidden or 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
| image: node:13.6.0-alpine | |
| variables: | |
| NODE_ENV: 'gitlab-ci' | |
| cache: | |
| paths: | |
| - node_modules/ | |
| - .yarn |
This file contains hidden or 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
| module.exports = { | |
| apps: [ | |
| { | |
| name: 'web app', | |
| exec_mode: 'cluster', | |
| instances: 4, | |
| script: './start.js', | |
| autorestart: true, | |
| max_memory_restart: '1G', |
This file contains hidden or 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
| module.exports = { | |
| apps: [ | |
| { | |
| name: 'web app', | |
| exec_mode: 'cluster', | |
| instances: 4, | |
| script: './node_modules/nuxt/bin/nuxt.js', | |
| args: 'start', | |
| autorestart: true, | |
| max_memory_restart: '1G', |
This file contains hidden or 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
| #!/bin/bash | |
| while read oldrev newrev ref | |
| do | |
| if [ "$ref" = "refs/heads/$BRANCH" ]; | |
| then | |
| ... | |
| else | |
| echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." | |
| fi | |
| done |
This file contains hidden or 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
| #!/bin/bash | |
| TARGET="/home/deploy/server" | |
| GIT_DIR="/home/deploy/git-hook" | |
| BRANCH="master" | |
| while read oldrev newrev ref | |
| do | |
| # only checking out the master (or whatever branch you would like to deploy) | |
| if [ "$ref" = "refs/heads/$BRANCH" ]; | |
| then |
This file contains hidden or 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
| mkdir git-hook | |
| cd git-hook/ | |
| git init - bare | |
| # Let's leave it here for a moment and install magnificent pm2 | |
| sudo npm install -g pm2 | |
| # And let's create server folder and pull repo there | |
| git clone REPO_URL server |
This file contains hidden or 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
| # First install curl and some last node version | |
| sudo apt-get install curl | |
| curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - | |
| # Install node and npm | |
| sudo apt-get install -y nodejs | |
| sudo npm install npm - global | |
| # Install n package | |
| sudo npm cache clean -f | |
| sudo npm install -g n | |
| sudo n stable |
This file contains hidden or 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
| PermitRootLogin no # forbid logging via root | |
| AllowUsers deploy # we want to connect as a new user though :) | |
| PasswordAuthentication yes # just to have it there until ssh key is deployed |
This file contains hidden or 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 will create a user and home directory. | |
| useradd -s /bin/bash -m -d /home/deploy -c "deploy" deploy | |
| # There you will add a password for new user | |
| passwd deploy | |
| # let new user use sudo | |
| usermod -aG sudo deploy |
This file contains hidden or 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
| import axios from 'axios'; | |
| //... | |
| const getSitemapBlogsFn = sitemapIndex => () => | |
| axios.get(`http://my.own.api/sitemap_routes?index=${sitemapIndex}`) | |
| .then(response => response && response.data) | |
| .then(offers => | |
| offers.map(({ code }) => ({ | |
| url: `http://myblog.org/blog/${code}`, | |
| changefreq: 'daily', | |
| priority: 1, |
NewerOlder