Skip to content

Commit

Permalink
feat(dev): add networking overrides to website Makefile (vectordotdev…
Browse files Browse the repository at this point in the history
…#18655)

This commit adds two new Makefile overrides for configuring the networking in the website Makefile:

* `SERVER_BIND`: Specify which network address to use in Hugo/HTTP servers for binding.
  The default value is `127.0.0.1` to preserve the current behavior.
* `SERVER_PORT`: Specify which port to use in Hugo/HTTP servers for listening.
  The default value is `1313` to preserve the current behavior.

Before this change, the Hugo/HTTP bind address and port was hard-coded to `127.0.0.1:1313`.
This behavior is not always convenient. For example, when running Hugo inside of a Docker container.
In this scenario, the Hugo/HTTP servers can be accessed form outside of the container as follows:

    make serve SERVER_BIND=0.0.0.0
    make run-production-site-locally SERVER_BIND=0.0.0.0

I also added a safety check for `DEPLOY_PRIME_URL` in the `preview-build` Makefile target. Without
this check, Hugo is incorrectly started with a bare `--baseURL` if that variable is not defined.

Signed-off-by: Hugo Hromic <hhromic@gmail.com>
  • Loading branch information
hhromic authored Sep 25, 2023
1 parent 21aec0c commit 75ebda0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions website/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
CUE = ./scripts/cue.sh

# Override to specify which network address to use in Hugo/HTTP servers for binding
export SERVER_BIND ?= 127.0.0.1
# Override to specify which port to use in Hugo/HTTP servers for listening
export SERVER_PORT ?= 1313

clean:
rm -rf public resources data/docs.json

Expand Down Expand Up @@ -33,6 +38,8 @@ structured-data: cue-build config-examples

serve: clean setup structured-data
hugo server \
--bind $(SERVER_BIND) \
--port $(SERVER_PORT) \
--buildDrafts \
--buildFuture \
--environment "development"
Expand All @@ -48,7 +55,7 @@ ci-production-build: setup structured-data production-build run-link-checker alg
# Preview site
preview-build:
hugo \
--baseURL $(DEPLOY_PRIME_URL) \
$(if $(DEPLOY_PRIME_URL),--baseURL $(DEPLOY_PRIME_URL),) \
--buildFuture \
--environment "preview" \
--minify
Expand All @@ -74,7 +81,7 @@ algolia:
# Useful for locally debugging issues that arise only on the deployed production site
run-production-site-locally:
make setup structured-data production-build
python3 -m http.server 1313 --directory ./public --bind 127.0.0.1
python3 -m http.server $(SERVER_PORT) --bind $(SERVER_BIND) --directory ./public

# Local dev build with no link checking and no Yarn dependency fetching
quick-build: clean structured-data production-build
Expand Down

0 comments on commit 75ebda0

Please sign in to comment.