forked from kubernetes/contributor-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add makefile and docker build support
- Loading branch information
Bob Killen
committed
Nov 9, 2018
1 parent
f911a57
commit 93ef0a3
Showing
5 changed files
with
126 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM alpine:latest | ||
ARG HUGO_VERSION=0.49.2 | ||
|
||
RUN apk add --no-cache \ | ||
bash \ | ||
git \ | ||
grep \ | ||
rsync \ | ||
sed | ||
|
||
RUN wget -qO- https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-64bit.tar.gz | \ | ||
tar xvz hugo -C /usr/local/bin \ | ||
&& mkdir -p /src \ | ||
&& addgroup -Sg 1000 hugo \ | ||
&& adduser -Sg hugo -u 1000 -g 1000 -h /src hugo | ||
|
||
WORKDIR /src | ||
|
||
EXPOSE 1313 | ||
|
||
USER hugo:hugo | ||
|
||
SHELL [ "/bin/bash", "-c" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
DIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
BUILD_DIR := $(join $(DIR), build) | ||
CONTENT_DIR := $(join $(DIR), content) | ||
DOCKER ?= docker | ||
DOCKER_IMAGE := k8s-contrib-site-hugo | ||
DOCKER_RUN := $(DOCKER) run --rm -it -v $(DIR):/src | ||
HUGO_VERSION := 0.49.2 | ||
|
||
.DEFAULT_GOAL := help | ||
|
||
.PHONY: targets docker-targets | ||
targets: help render serve clean-all clean-build clean-content | ||
docker-targets: docker-image docker-build docker-serve docker-gen-site docker-gen-site-ci | ||
|
||
help: ## Show this help text. | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | ||
|
||
render: ## Build Hugo site. | ||
hugo | ||
|
||
server: ## Start Hugo webserver. | ||
hugo server --ignoreCache --disableFastRender | ||
|
||
gen-site: ## Generate Contributor Site content. | ||
./gen-site.sh | ||
|
||
gen-site-ci: ## Generate Contributor Site content as if called from CI system. | ||
CI_BUILD=true ./gen-site.sh | ||
|
||
docker-image: ## Build container imagefor use with docker-* targets. | ||
$(DOCKER) build . -t $(DOCKER_IMAGE) --build-arg HUGO_VERSION=$(HUGO_VERSION) | ||
|
||
docker-render: ## Build Hugo site executing within a container (equiv to render). | ||
$(DOCKER_RUN) $(DOCKER_IMAGE) hugo | ||
|
||
docker-server: ## Start Hugo webserver executing within a container (equiv to server). | ||
$(DOCKER_RUN) -p 1313:1313 $(DOCKER_IMAGE) hugo server --watch --bind 0.0.0.0 | ||
|
||
docker-gen-site: ## Generate Contributor Site content executing within a container (equiv to gen-site). | ||
$(DOCKER_RUN) $(DOCKER_IMAGE) ./gen-site.sh | ||
|
||
docker-gen-site-ci: ## Generate Contributor Site content as if called from CI system (equiv to gen-site-ci). | ||
$(DOCKER_RUN) -e CI_BUILD=true $(DOCKER_IMAGE) ./gen-site.sh | ||
|
||
clean-all: clean-build clean-content clean-docker ## Executes clean-build, clean-content, and clean-docker. | ||
|
||
clean-build: ## Cleans build dependnecies. | ||
[ -d $(BUILD_DIR) ] && rm -rf $(BUILD_DIR)/* | ||
|
||
clean-content: ## Cleans generated content. | ||
[ -d $(CONTENT_DIR) ] && rm -rf $(CONTENT_DIR)/* | ||
|
||
clean-docker: ## Removes docker image if found. | ||
$(DOCKER) rmi $(DOCKER_IMAGE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters