Skip to content

manudiv/richardwillis.info

 
 

Repository files navigation

RichardWillis.info

Analyze Prod deploy

This is a Next.js project bootstrapped with create-next-app.

Getting Started

Install deps & run the development server:

npm install
npm run dev

Open http://localhost:3000 with your browser to see the result.

Adding Blog Entries

Add new entries as markdown files to blog/.

Docker

Build & run the Node.js image:

docker build -t badsyntax/richardwillis --build-arg ASSET_PREFIX=/ .
docker run --publish 3000:3000 badsyntax/richardwillis

# or
docker-compose up --remove-orphans

Manual Deploy

First build & push the docker image:

echo $CR_PAT | docker login ghcr.io -u badsyntax --password-stdin
docker build -t ghcr.io/badsyntax/richardwillis:latest --build-arg ASSET_PREFIX=/ .
docker run --publish 3000:3000 ghcr.io/badsyntax/richardwillis:latest
docker push ghcr.io/badsyntax/richardwillis:latest

Now pull & deploy the image on the dokku server:

dokku apps:create richardwillis
dokku proxy:ports-add richardwillis http:80:3000
dokku proxy:ports-remove richardwillis http:3000:3000
echo $CR_PAT | docker login ghcr.io -u badsyntax --password-stdin
docker pull ghcr.io/badsyntax/richardwillis:latest
docker tag ghcr.io/badsyntax/richardwillis:latest dokku/richardwillis:latest
dokku tags:deploy richardwillis latest
dokku letsencrypt richardwillis
dokku domains:add richardwillis richardwillis.info

Set up Prometheus with dokku

dokku apps:create prometheus
dokku proxy:ports-add prometheus http:80:9090
dokku proxy:ports-remove prometheus http:9090:9090

mkdir -p /var/lib/dokku/data/storage/prometheus
chown nobody /var/lib/dokku/data/storage/prometheus
dokku storage:mount prometheus "/var/lib/dokku/data/storage/prometheus:/prometheus"
dokku storage:mount prometheus "/home/dokku/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml"

dokku config:set prometheus DOKKU_DOCKERFILE_START_CMD="--config.file=/etc/prometheus/prometheus.yml
  --storage.tsdb.path=/prometheus
  --web.console.libraries=/usr/share/prometheus/console_libraries
  --web.console.templates=/usr/share/prometheus/consoles
  --storage.tsdb.no-lockfile"

dokku docker-options:add prometheus build,deploy,run "--link richardwillis.web.1:richardwillis"

## Add contents of ./prometheus/prometheus.yml to /home/dokku/prometheus/prometheus.yml

docker pull prom/prometheus:latest
docker tag prom/prometheus:latest dokku/prometheus:latest
dokku tags:deploy prometheus latest
dokku

Setup staticman

On your local machine:

cd staticman
docker build -t ghcr.io/badsyntax/staticman:latest .
echo $CR_PAT | docker login ghcr.io -u badsyntax --password-stdin
docker push ghcr.io/badsyntax/staticman:latest

# Run locally
ssh-keygen -m PEM -t rsa -b 4096 -C "staticman key" -f ~/.ssh/staticman -q -N ""
docker run --publish 3002:3000 -e "RSA_PRIVATE_KEY=$(cat ~/.ssh/staticman)" ghcr.io/badsyntax/staticman:latest

On the dokku server:

dokku apps:create staticman
dokku proxy:ports-add staticman http:80:3000

# Create the private key with an empty passphrase
ssh-keygen -m PEM -t rsa -b 4096 -C "staticman key" -f ~/.ssh/staticman -q -N ""
dokku config:set --encoded --no-restart staticman RSA_PRIVATE_KEY="$(base64 ~/.ssh/staticman)"
dokku config:set staticman --no-restart GITHUB_TOKEN=YOUR_GITHUB_TOKEN PORT=3000

docker pull ghcr.io/badsyntax/staticman:latest
docker tag ghcr.io/badsyntax/staticman:latest dokku/staticman:latest

dokku domains:add staticman staticman.richardwillis.info
dokku tags:deploy staticman latest
dokku letsencrypt staticman

Github actions

  • AWS_ACCESS_KEY_ID
  • AWS_S3_BUCKET
  • AWS_SECRET_ACCESS_KEY
  • CR_PAT
  • DOKKU_HOST (eg dokku.example.com)
  • DOKKU_SSH_PRIVATE_KEY
  • GIT_REMOTE_URL (eg ssh://[email protected]:22/appname);
  • RELEASE_DRAFTER_TOKEN_GITHUB
  • GRAFANA_AUTH_TOKEN (deploy annotations)

Providing a SSH key

ssh-keygen -N "" -f ~/.ssh/dokkugithubactions
cat ~/.ssh/dokkugithubactions.pub | ssh [email protected] dokku ssh-keys:add GITHUB_ACTIONS

Now provide the contents of ~/.ssh/dokkugithubactions as DOKKU_SSH_PRIVATE_KEY

About

My personal website

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 79.7%
  • CSS 13.5%
  • JavaScript 3.2%
  • Dockerfile 2.7%
  • Shell 0.9%