From 85e9d83cf574ee6ad3e1af21ed918a0dd67455cf Mon Sep 17 00:00:00 2001 From: Bastian de Byl Date: Mon, 28 Jan 2019 23:50:47 -0500 Subject: [PATCH] Reworked Makefile to use Docker images, updated README --- .gitignore | 1 - Makefile | 14 ++++++++++---- README.md | 18 ++++++++++++++---- docker/Dockerfile | 17 ----------------- 4 files changed, 24 insertions(+), 26 deletions(-) delete mode 100644 docker/Dockerfile diff --git a/.gitignore b/.gitignore index a0e3cd2..35462be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -archetypes/ flymd* public/ resources/ diff --git a/Makefile b/Makefile index b405504..4dab30e 100644 --- a/Makefile +++ b/Makefile @@ -4,20 +4,26 @@ # - path to web root (in /tmp directory) WEBSITE=bdebyl.net +DOCKER_IMAGE_NAME=bdebyl/hugo +DOCKER_IMAGE_TAG=0.2 +DOCKER_IMAGE=$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) + +DOCKER_RUN=docker run --rm -v $(shell pwd):/src -p 127.0.0.1:1313:1313/tcp + # 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' \ + --query 'DistributionList.Items[].(id:Id,a:Aliases.Items)[?contains(a,`$(WEBSITE)`)].id' \ --output text) build: - hugo + $(DOCKER_RUN) $(DOCKER_IMAGE) run: - hugo server + $(DOCKER_RUN) $(DOCKER_IMAGE) server --bind=0.0.0.0 clean: @# Clean up existing generated site - rm -rf public/ + rm -rf public/ resources/ deploy: clean build @# Upload files to S3 diff --git a/README.md b/README.md index 7fcc787..7080d37 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,25 @@ etc. The binary static content is all hosted on S3 (i.e. `.jpeg`, `.png`, etc.). It was setup using **Terraform**, or more specifically [alimac/terraform-s3 (from commit 4b32c8d)](https://github.com/alimac/terraform-s3/tree/4b32c8d336ffacc4318c065f8d135973210f535c) -- -big thank you to @alimac on GitHub for that! +big thank you to [**@alimac**](https://github.com/alimac/) on GitHub for that! # Usage -The Makefile is a simple wrapper for `hugo` and `aws s3`, but provides useful -short commands to test the hugo site locally and deploy it to AWS. +The Makefile is a simple wrapper for the `bdebyl/hugo` Docker image and `aws +s3`, but provides useful short commands to test the hugo site locally and deploy +it to AWS. + +## Dependencies +[Docker](https://docs.docker.com/install/) is required to run the make targets +for hosting and generating the static Hugo site. ## Development -Simply start the Hugo server: +To build the static content _without_ running the Hugo server: +``` +make build +``` + +To start the Hugo server on `http://localhost:1313`: ``` make run ``` diff --git a/docker/Dockerfile b/docker/Dockerfile deleted file mode 100644 index 9e71983..0000000 --- a/docker/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM alpine:3.7 -MAINTAINER Bastian de Byl - -ENV HUGO_DIR /usr/local/hugo -ENV HUGO_BIN_DIR /usr/local/bin -ENV HUGO_RELEASE_VER 0.52 - -RUN mkdir ${HUGO_DIR} -ADD https://github.com/gohugoio/hugo/releases/download/v${HUGO_RELEASE_VER}/hugo_${HUGO_RELEASE_VER}_Linux-64bit.tar.gz ${HUGO_DIR} -RUN find ${HUGO_DIR} -name "hugo*.tar.gz" -exec tar xzvf {} -C ${HUGO_DIR} \; -exec rm -v {} \; \ - && ln -s ${HUGO_DIR}/hugo ${HUGO_BIN_DIR} - -VOLUME /src -WORKDIR /src - -EXPOSE 1313 -CMD hugo server --baseURL=http://localhost:1313 --bind=0.0.0.0