Skip to content

Dermah/blog.dermah.com

Repository files navigation

blog.dermah.com

Static site blog src for blog.dermah.com

Prerequisites

You need git-lfs!

brew install git-lfs
git lfs install

To push and pull Git LFS objects (*.jpg, *.png), you may need to be running the local lfs server

npm run lfs-server

This assumes you have the AWS CLI and credentials configured. Try using aws-vault to manage many profiles.

Clone

Using my own lfs-server has made this a chore. Just check out the lfs-server first:

git clone https://github.com/dermah/blog.dermah.com.git --no-checkout
cd blog.dermah.com
git checkout master package.json lfs-server/

Run the server in another terminal:

npm run lfs-server

Then check out everything else:

git checkout master .

Install

npm install

Dev

npm run serve

Build

npm run build

Pre-deploy File Diff

  • Files present on S3 but not in dist/ are red.
  • New files to deploy to S3 are green.
npm run filediff

If you want to see the diff of the file contents:

npm run diff
# Or do this if you've already downloaded the bucket recently:
# npm run diff -- --show-only

Deploy

npm run deploy -- --dryrun
npm run deploy
npm run decache

Update the blog status, git add your changes then

npm version minor -f -m "<blog status>"
git push --follow-tags

Other Stuff

Strip metadata from all images in a directory

# brew install exiftool
exiftool -all= *.jpg

Recommended max dimension: 1500px


Infrastructure

You'll need the AWS CLI installed and configured.

CloudFront can only use ACM certificates from the us-east-1 region, so this stack must be deployed there. Set this environment variable to operate in us-east-1:

AWS_REGION=us-east-1

Validate

aws cloudformation validate-template --template-body file://infrastructure.yml

Create

# BYOHostedZoneID=<Existing Hosted Zone>
aws cloudformation create-stack --template-body file://infrastructure.yml --stack-name blog-dermah-com --parameters \
  ParameterKey=DomainName,ParameterValue=blog.dermah.com \
  ParameterKey=BYOHostedZoneID,ParameterValue=$BYOHostedZoneID
aws cloudformation wait stack-create-complete --stack-name blog-dermah-com
aws cloudformation describe-stacks --stack-name blog-dermah-com

Diff

aws cloudformation get-template --stack-name blog-dermah-com --query TemplateBody --output text | git diff --no-index - infrastructure.yml

Update

aws cloudformation update-stack --template-body file://infrastructure.yml --stack-name blog-dermah-com --parameters \
  ParameterKey=DomainName,UsePreviousValue=true \
  ParameterKey=BYOHostedZoneID,UsePreviousValue=true
aws cloudformation wait stack-update-complete --stack-name blog-dermah-com

Describe

aws cloudformation describe-stacks --stack-name blog-dermah-com
aws cloudformation describe-stacks --stack-name blog-dermah-com --query "Stacks[0].Outputs"
aws cloudformation describe-stack-events --stack-name blog-dermah-com --query "StackEvents[*].{ID:LogicalResourceId,Type:ResourceType,Status:ResourceStatus,Time:Timestamp,Reason:ResourceStatusReason}"

Writing

Write a draft post

Do this in your post front matter

draft: true        # removes the item from collections
permalink: false   # does not output the file during build