Updated Makefile phonies
This commit is contained in:
33
Makefile
33
Makefile
@@ -2,7 +2,8 @@
|
|||||||
# Website hostname, used to set:
|
# Website hostname, used to set:
|
||||||
# - image and container names
|
# - image and container names
|
||||||
# - path to web root (in /tmp directory)
|
# - path to web root (in /tmp directory)
|
||||||
WEBSITE=bdebyl.net
|
WEB_BUCKET=bdebyl.net
|
||||||
|
STATIC_BUCKET=bdebyl.static
|
||||||
STATIC_DIR=static
|
STATIC_DIR=static
|
||||||
|
|
||||||
HUGO_IMAGE_NAME=bdebyl/hugo
|
HUGO_IMAGE_NAME=bdebyl/hugo
|
||||||
@@ -25,41 +26,55 @@ DOCKER_RUN=docker run --rm ${RUN_USER} ${RUN_VOL}
|
|||||||
|
|
||||||
# Look up CloudFront distribution ID based on website alias
|
# Look up CloudFront distribution ID based on website alias
|
||||||
DISTRIBUTION_ID=$(shell docker run --rm ${AWS_ENV} ${AWS_IMAGE} cloudfront list-distributions \
|
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' \
|
--query 'DistributionList.Items[].{id:Id,a:Aliases.Items}[?contains(a,`${WEB_BUCKET}`)].id' \
|
||||||
--output text)
|
--output text)
|
||||||
S3_CMD=s3 sync --acl "public-read" --sse "AES256" public/ s3://${WEBSITE}
|
S3_CMD=s3 sync --acl "public-read" --sse "AES256" public/ s3://${WEB_BUCKET}
|
||||||
CLOUDFRONT_CMD=cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths '/*'
|
CLOUDFRONT_CMD=cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths '/*'
|
||||||
|
|
||||||
|
all: build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(DOCKER_RUN) ${HUGO_IMAGE}
|
$(DOCKER_RUN) ${HUGO_IMAGE}
|
||||||
|
.PHONY: build
|
||||||
|
|
||||||
mount:
|
static-pull:
|
||||||
if [ ! -d "${STATIC_DIR}/static" ]; then aws s3 sync s3://bdebyl.static static/; fi
|
if [ ! -d "${STATIC_DIR}/static" ]; then aws s3 sync s3://${STATIC_BUCKET} ${STATIC_DIR}/; fi
|
||||||
|
.PHONY: static-pull
|
||||||
|
|
||||||
unmount:
|
static-push:
|
||||||
if [ -d "${STATIC_DIR}/static" ]; then rm -rfv static/
|
aws s3 sync --acl "public-read" --sse "AES256" s3://${STATIC_BUCKET} ${STATIC_DIR}/
|
||||||
|
.PHONY: static-push
|
||||||
|
|
||||||
run:
|
run: static-pull
|
||||||
-$(DOCKER_RUN) -it ${DOCKER_PORT} ${HUGO_IMAGE} -D server --bind=0.0.0.0
|
-$(DOCKER_RUN) -it ${DOCKER_PORT} ${HUGO_IMAGE} -D server --bind=0.0.0.0
|
||||||
|
.PHONY: run
|
||||||
|
|
||||||
version:
|
version:
|
||||||
$(DOCKER_RUN) ${HUGO_IMAGE} version
|
$(DOCKER_RUN) ${HUGO_IMAGE} version
|
||||||
|
.PHONY: version
|
||||||
|
|
||||||
new:
|
new:
|
||||||
$(DOCKER_RUN) ${HUGO_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)
|
||||||
|
.PHONY: new
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@# Clean up existing generated site
|
@# Clean up existing generated site
|
||||||
rm -rf public/ resources/
|
rm -rf public/ resources/
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
static-clean:
|
||||||
|
if [ -d "${STATIC_DIR}/static" ]; then rm -rfv static/
|
||||||
|
.PHONY: static-clean
|
||||||
|
|
||||||
deploy: clean build
|
deploy: clean build
|
||||||
@# Upload files to S3
|
@# Upload files to S3
|
||||||
@$(DOCKER_RUN) ${AWS_ENV} ${AWS_IMAGE} ${S3_CMD}
|
@$(DOCKER_RUN) ${AWS_ENV} ${AWS_IMAGE} ${S3_CMD}
|
||||||
|
.PHONY: deploy
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
@# Invalidate caches
|
@# Invalidate caches
|
||||||
@$(DOCKER_RUN) ${AWS_ENV} ${AWS_IMAGE} ${CLOUDFRONT_CMD}
|
@$(DOCKER_RUN) ${AWS_ENV} ${AWS_IMAGE} ${CLOUDFRONT_CMD}
|
||||||
|
.PHONY: cache
|
||||||
|
|
||||||
# Default target for make (<=3.80)
|
# Default target for make (<=3.80)
|
||||||
.PHONY: static mount unmount build _run run version new clean deploy cache
|
|
||||||
default: build
|
default: build
|
||||||
|
|||||||
Reference in New Issue
Block a user