diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 101 |
1 files changed, 83 insertions, 18 deletions
@@ -1,7 +1,5 @@ -HUGO := hugo HUGO_VERSION := 0.53 HTMLPROOFER_VERSION := 3.10.2 -NPM := npm GCLOUD := gcloud GCP_PROJECT := gvisor-website @@ -15,7 +13,7 @@ CONTENT_SOURCE = $(wildcard content/*) default: website .PHONY: default -website: all-upstream app public/static +website: all-upstream app static-production .PHONY: website app: $(APP_TARGET) @@ -45,16 +43,59 @@ content/docs/community/sigs: upstream/community $(wildcard upstream/community/si $(APP_TARGET): public $(APP_SOURCE) cp -a cmd/gvisor-website/$(patsubst public/%,%,$@) public/ -public/static: compatibility-docs node_modules config.toml $(shell find archetypes assets content themes -type f | sed 's/ /\\ /g') - HUGO_ENV="production" $(HUGO) +static-production: hugo-docker-image compatibility-docs node_modules config.toml $(shell find archetypes assets content themes -type f | sed 's/ /\\ /g') + docker run \ + --rm \ + -e HUGO_ENV="production" \ + -e USER="$(shell id -u)" \ + -e HOME="/tmp" \ + -u="$(shell id -u):$(shell id -g)" \ + -v $(PWD):/workspace \ + -w /workspace \ + gcr.io/gvisor-website/hugo:$(HUGO_VERSION) \ + hugo +.PHONY: static-production + +static-staging: hugo-docker-image compatibility-docs node_modules config.toml $(shell find archetypes assets content themes -type f | sed 's/ /\\ /g') + docker run \ + --rm \ + -e HUGO_ENV="production" \ + -e USER="$(shell id -u)" \ + -e HOME="/tmp" \ + -u="$(shell id -u):$(shell id -g)" \ + -v $(PWD):/workspace \ + -w /workspace \ + gcr.io/gvisor-website/hugo:$(HUGO_VERSION) \ + hugo \ + -b "https://staging-$(shell git branch | grep \* | cut -d ' ' -f2)-dot-gvisor-website.appspot.com" +.PHONY: static-staging node_modules: package.json package-lock.json # Use npm ci because npm install will update the package-lock.json. # See: https://github.com/npm/npm/issues/18286 - $(NPM) ci + docker run \ + --rm \ + -e USER="$(shell id -u)" \ + -e HOME="/tmp" \ + -u="$(shell id -u):$(shell id -g)" \ + -v $(PWD):/workspace \ + -w /workspace \ + --entrypoint 'npm' \ + node ci upstream/gvisor/bazel-bin/runsc/linux_amd64_pure_stripped/runsc: upstream-gvisor - cd upstream/gvisor && bazel build runsc + mkdir -p /tmp/gvisor-website/build_output + docker run \ + --rm \ + -v $(PWD)/upstream/gvisor:/workspace \ + -v /tmp/gvisor-website/build_output:/tmp/gvisor-website/build_output \ + -w /workspace \ + --entrypoint 'sh' \ + l.gcr.io/google/bazel \ + -c '\ + groupadd --gid $(shell id -g) $(shell id -gn) && \ + useradd --uid $(shell id -u) --gid $(shell id -g) -ms /bin/bash $(USER) && \ + su $(USER) -c "bazel --output_user_root=/tmp/gvisor-website/build_output build //runsc"' bin/generate-syscall-docs: $(GEN_SOURCE) mkdir -p bin/ @@ -65,10 +106,22 @@ compatibility-docs: bin/generate-syscall-docs upstream/gvisor/bazel-bin/runsc/li .PHONY: compatibility-docs check: check-markdown check-html + docker run \ + -v $(shell pwd)/public:/public gcr.io/gvisor-website/html-proofer:$(HTMLPROOFER_VERSION) \ + htmlproofer --disable-external --check-html public/static .PHONY: check check-markdown: node_modules $(CONTENT_SOURCE) compatibility-docs - npm run lint-md + docker run \ + --rm \ + -e USER="$(shell id -u)" \ + -e HOME="/tmp" \ + -u="$(shell id -u):$(shell id -g)" \ + -v $(PWD):/workspace \ + -v /tmp:/tmp \ + -w /workspace \ + --entrypoint 'npm' \ + node run lint-md .PHONY: check-markdown check-html: website @@ -76,18 +129,32 @@ check-html: website .PHONY: check-html # Run a local content development server. Redirects will not be supported. -devserver: all-upstream compatibility-docs - $(HUGO) server -FD --port 8080 +devserver: hugo-docker-image all-upstream compatibility-docs + docker run \ + --rm \ + -e USER="$(shell id -u)" \ + -e HOME="/tmp" \ + -u="$(shell id -u):$(shell id -g)" \ + -v $(PWD):/workspace \ + -w /workspace \ + -p 8080:8080 \ + gcr.io/gvisor-website/hugo:$(HUGO_VERSION) \ + hugo server \ + -FD \ + --bind 0.0.0.0 \ + --port 8080 .PHONY: server server: website cd public/ && go run main.go --custom-domain localhost .PHONY: server -# Deploy the website to App Engine. -deploy: $(APP_TARGET) - cd public && $(GCLOUD) app deploy -.PHONY: deploy +# Stage the website to App Engine at a version based on the git branch name. +stage: all-upstream app static-staging + # Disallow indexing staged content. + printf "User-agent: *\nDisallow: /" > public/static/robots.txt + cd public && $(GCLOUD) app deploy -v staging-$(shell git branch | grep \* | cut -d ' ' -f2) --no-promote +.PHONY: stage # CI related Commmands ############################################################################## @@ -96,16 +163,14 @@ deploy: $(APP_TARGET) cloud-build: gcloud builds submit --config cloudbuild.yaml . -# Build and push the hugo Docker image used by Cloud Build. +# Build the hugo Docker image. hugo-docker-image: docker build --build-arg HUGO_VERSION=$(HUGO_VERSION) -t gcr.io/gvisor-website/hugo:$(HUGO_VERSION) cloudbuild/hugo/ - docker push gcr.io/gvisor-website/hugo:$(HUGO_VERSION) .PHONY: hugo-docker-image -# Build and push the html-proofer image used by Cloud Build. +# Build the html-proofer image used by Cloud Build. htmlproofer-docker-image: docker build --build-arg HTMLPROOFER_VERSION=$(HTMLPROOFER_VERSION) -t gcr.io/gvisor-website/html-proofer:$(HTMLPROOFER_VERSION) cloudbuild/html-proofer/ - docker push gcr.io/gvisor-website/html-proofer:$(HTMLPROOFER_VERSION) .PHONY: htmlproofer-docker-image clean: |