/
Makefile
52 lines (42 loc) · 1.69 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
WEBSITE_REPO=github.com/hashicorp/terraform-website
WEBSITE_BRANCH=master
CURRENT_GIT_REPO=$$(basename `git rev-parse --show-toplevel`)
CURRENT_GIT_BRANCH=$$(git rev-parse --abbrev-ref HEAD)
WEBSITE_DOCKER_IMAGE="hashicorp/terraform-website:full"
WEBSITE_DOCKER_IMAGE_LOCAL="hashicorp-terraform-website-local"
WEBSITE_DOCKER_RUN_FLAGS=--interactive \
--rm \
--tty \
--workdir "/website" \
--volume "$(shell pwd)/website:/website/preview" \
--publish "3000:3000" \
-e "IS_CONTENT_PREVIEW=true" \
-e "PREVIEW_FROM_REPO=$(CURRENT_GIT_REPO)" \
-e "NAV_DATA_DIRNAME=./preview/data" \
-e "CONTENT_DIRNAME=./preview/docs" \
-e "CURRENT_GIT_BRANCH=$(CURRENT_GIT_BRANCH)"
# Run the terraform.io website to preview local content changes
website:
@echo "==> Downloading latest Docker image..."
@docker pull ${WEBSITE_DOCKER_IMAGE}
@echo "==> Starting website in Docker..."
@docker run ${WEBSITE_DOCKER_RUN_FLAGS} ${WEBSITE_DOCKER_IMAGE} npm start
# Run the terraform.io website via a locally built docker image
#
# This is useful for development as you may be building an image
# with local changes from the `terraform-website` repo.
website/local:
@echo "==> Starting website in Docker..."
@docker run ${WEBSITE_DOCKER_RUN_FLAGS} ${WEBSITE_DOCKER_IMAGE_LOCAL} npm start
# Build the terraform.io image using `terraform-website` git repo as the build context
website/build-local:
@echo "==> Building local Docker image"
@docker build https://github.com/hashicorp/terraform-website.git\#$(WEBSITE_BRANCH) \
-t $(WEBSITE_DOCKER_IMAGE_LOCAL)
lint:
golangci-lint run
fmt:
gofmt -s -w -e .
test:
go test -v -cover -timeout=120s -parallel=4 ./...
.PHONY: lint fmt test website website/local website/build-local