Skip to content

Instantly share code, notes, and snippets.

View starikovm's full-sized avatar
🎯
Focusing

Mikhail Starikov starikovm

🎯
Focusing
  • Leapsome
  • Berlin
View GitHub Profile
@starikovm
starikovm / .gitlab-ci.yml
Created February 10, 2020 12:32
gitlab-ci.yml to deploy on Digital ocean droplet
image: node:13.6.0-alpine
variables:
NODE_ENV: 'gitlab-ci'
cache:
paths:
- node_modules/
- .yarn
@starikovm
starikovm / ecosystem.config.js
Last active February 10, 2020 12:13
Configuration file for pm2
module.exports = {
apps: [
{
name: 'web app',
exec_mode: 'cluster',
instances: 4,
script: './start.js',
autorestart: true,
max_memory_restart: '1G',
@starikovm
starikovm / ecosystem.config.js
Last active February 10, 2020 12:13
ecosystem.config.js for nuxt web application
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',
@starikovm
starikovm / post-receive
Created February 9, 2020 20:01
Check that we do stuff only on master push
#!/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
@starikovm
starikovm / post-receive
Last active February 10, 2020 11:53
Git post-receive hook
#!/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
@starikovm
starikovm / .bash
Created February 9, 2020 19:57
Create a bare repo and some basic setup
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
@starikovm
starikovm / .bash
Created February 9, 2020 19:54
Install needed version of node
# 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
@starikovm
starikovm / sshd_config
Last active February 9, 2020 19:51
Set these values in sshd_config
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
@starikovm
starikovm / .bash
Created February 9, 2020 19:42
Create a new user and give him sudo rights
# 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
@starikovm
starikovm / nuxt.config.js
Last active November 8, 2019 17:20
Creating multi index sitemap
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,