DevOps


Notes and step-by-step for setting up local and remote server development environments.


GitHub

1. Add remote origin

git remote rm origin

git remote add origin git@github.com:l00sed/[repo name].git

git push -u origin master

Ghost Headless CMS

1. Install Yarn

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/

sudo apt update && sudo apt install yarn

2. Install Ghost CLI

yarn global add ghost-cli
mkdir ghost-admin && cd ghost-admin

ghost install local

3. Install Gatsby-Ghost Integration Boilerplate

git clone https://github.com/TryGhost/gatsby-starter-ghost.git

cd gatsby-starter-ghost

yarn install

yarn dev
{
  "development": {
    "apiUrl": "https://localhost:2368",
    "contentApiKey": "[API KEY]"
  }
}

5. Ghost-Gatsby-Nginx docker-compose.yml

version: '3'
services:

  ghost:
    image: ghost:latest
    restart: always
    depends_on:
      - db
    environment:
      url: https://example.com
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: your_database_root_password
      database__connection__database: ghost
    volumes:
      - /opt/ghost_content:/var/lib/ghost/content

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: your_database_root_password
    volumes:
      - /opt/ghost_mysql:/var/lib/mysql

  nginx:
    build:
      context: ./nginx
      dockerfile: Dockerfile
    restart: always
    depends_on:
      - ghost
    ports:
      - "80:80"
      - "443:443"
    volumes:
       - /etc/letsencrypt/:/etc/letsencrypt/
       - /usr/share/nginx/html:/usr/share/nginx/html

Certbot

sudo apt install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install certbot
sudo certbot certonly --standalone -d example.com

Docker

Community Edition Docker Daemon

  1. Remove any previous installs of Docker
sudo apt remove docker docker-engine docker.io
  1. Prerequisites
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg
  1. Add Docker GPG
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  1. Verify fingerprint
sudo apt-key fingerprint 0EBFCD88
  1. Add stable Docker repo
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  1. Install Docker
sudo apt update
sudo apt install docker-ce
  1. Add user to docker group
sudo usermod -aG docker $USER

Docker Compose

  1. Download docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
  1. Make executable
sudo chmod +x /usr/local/bin/docker-compose
  1. Clean slate
docker-compose down -v --rmi all --remove-orphans

Node / NVM / npm

  1. Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash