Updated changes to reflect new static layout
This commit is contained in:
48
Makefile
48
Makefile
@@ -3,31 +3,51 @@
|
||||
# - image and container names
|
||||
# - path to web root (in /tmp directory)
|
||||
WEBSITE=bdebyl.net
|
||||
STATIC_DIR=static
|
||||
|
||||
DOCKER_IMAGE_NAME=bdebyl/hugo
|
||||
DOCKER_IMAGE_TAG=0.2
|
||||
DOCKER_IMAGE=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
|
||||
HUGO_IMAGE_NAME=bdebyl/hugo
|
||||
HUGO_IMAGE_TAG=0.4
|
||||
HUGO_IMAGE=$(HUGO_IMAGE_NAME):$(HUGO_IMAGE_TAG)
|
||||
|
||||
AWS_IMAGE_NAME=bdebyl/awscli
|
||||
AWS_IMAGE_TAG=0.2
|
||||
AWS_IMAGE=$(AWS_IMAGE_NAME):$(AWS_IMAGE_TAG)
|
||||
|
||||
# Container Variables
|
||||
RUN_USER=--user $(shell id -u $$USER):$(shell id -g $$USER)
|
||||
RUN_VOL=-v $(shell pwd):/src
|
||||
AWS_ENV=-e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" -e "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}" -e "AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}"
|
||||
S3_CMD=s3 sync --acl "public-read" --sse "AES256" public/ s3://${WEBSITE}
|
||||
|
||||
DOCKER_PORT=-p 1313:1313/tcp
|
||||
DOCKER_RUN=docker run -it --rm ${RUN_USER} ${RUN_VOL}
|
||||
|
||||
# Look up CloudFront distribution ID based on website alias
|
||||
DISTRIBUTION_ID=$(shell aws cloudfront list-distributions \
|
||||
--query 'DistributionList.Items[].{id:Id,a:Aliases.Items}[?contains(a,`$(WEBSITE)`)].id' \
|
||||
DISTRIBUTION_ID=$(shell docker run --rm ${AWS_ENV} ${AWS_IMAGE} cloudfront list-distributions \
|
||||
--query 'DistributionList.Items[].{id:Id,a:Aliases.Items}[?contains(a,`${WEBSITE}`)].id' \
|
||||
--output text)
|
||||
|
||||
build:
|
||||
$(DOCKER_RUN) ${DOCKER_IMAGE}
|
||||
dist:
|
||||
@echo ${DISTRIBUTION_ID}
|
||||
|
||||
run:
|
||||
$(DOCKER_RUN) ${DOCKER_PORT} ${DOCKER_IMAGE} server --bind=0.0.0.0 -D
|
||||
static:
|
||||
s3fs -o use_path_request_style bdebyl.static ${STATIC_DIR}
|
||||
|
||||
unmount:
|
||||
fusermount -u ${STATIC_DIR}
|
||||
|
||||
build:
|
||||
$(DOCKER_RUN) ${HUGO_IMAGE}
|
||||
|
||||
_run: static
|
||||
-$(DOCKER_RUN) ${DOCKER_PORT} ${HUGO_IMAGE} server --bind=0.0.0.0
|
||||
run: _run unmount
|
||||
|
||||
version:
|
||||
$(DOCKER_RUN) ${HUGO_IMAGE} version
|
||||
|
||||
new:
|
||||
$(DOCKER_RUN) ${DOCKER_IMAGE} new post/$(shell read -p "Post Name (i.e. my_post.md): " pn; echo $$pn)
|
||||
$(DOCKER_RUN) ${HUGO_IMAGE} new post/$(shell read -p "Post Name (i.e. my_post.md): " pn; echo $$pn)
|
||||
|
||||
thumbnails:
|
||||
@./make-thumbs.sh
|
||||
@@ -38,12 +58,12 @@ clean:
|
||||
|
||||
deploy: clean build
|
||||
@# Upload files to S3
|
||||
aws s3 sync --acl "public-read" --sse "AES256" public/ s3://$(WEBSITE)
|
||||
@$(DOCKER_RUN) ${AWS_ENV} ${AWS_IMAGE} ${S3_CMD}
|
||||
|
||||
cache:
|
||||
@# Invalidate caches
|
||||
aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths '/*'
|
||||
@cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths '/*'
|
||||
|
||||
# Default target for make (<=3.80)
|
||||
.PHONY: build run deploy
|
||||
default: run
|
||||
.PHONY: static unmount build _run run version new thumbnails clean deploy cache
|
||||
default: build
|
||||
|
||||
Reference in New Issue
Block a user