Skip to content

Commit

Permalink
chore: update website scripts (release/1.3.x) (#16385)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryce Kalow authored Mar 9, 2023
1 parent db9f4fa commit bcc7f2d
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 8 deletions.
33 changes: 27 additions & 6 deletions website/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
######################################################
# NOTE: This file is managed by the Digital Team's #
# Terraform configuration @ hashicorp/mktg-terraform #
######################################################

.DEFAULT_GOAL := website

# Set the preview mode for the website shell to "developer" or "io"
PREVIEW_MODE ?= developer
REPO ?= nomad

# Enable setting alternate docker tool, e.g. 'make DOCKER_CMD=podman'
DOCKER_CMD ?= docker

CURRENT_GIT_BRANCH=$$(git rev-parse --abbrev-ref HEAD)
LOCAL_CONTENT_DIR=
PWD=$$(pwd)

DOCKER_IMAGE="hashicorp/dev-portal"
DOCKER_IMAGE_LOCAL="dev-portal-local"
DOCKER_RUN_FLAGS=-it \
Expand All @@ -13,26 +28,32 @@ DOCKER_RUN_FLAGS=-it \
--volume "$(PWD)/redirects.js:/app/redirects.js" \
--volume "next-dir:/app/website-preview/.next" \
--volume "$(PWD)/.env:/app/.env" \
-e "REPO=nomad"
--volume "$(PWD)/.env.development:/app/website-preview/.env.development" \
--volume "$(PWD)/.env.local:/app/website-preview/.env.local" \
-e "REPO=$(REPO)" \
-e "PREVIEW_FROM_REPO=$(REPO)" \
-e "IS_CONTENT_PREVIEW=true" \
-e "LOCAL_CONTENT_DIR=$(LOCAL_CONTENT_DIR)" \
-e "CURRENT_GIT_BRANCH=$(CURRENT_GIT_BRANCH)" \
-e "PREVIEW_MODE=$(PREVIEW_MODE)"

# Default: run this if working on the website locally to run in watch mode.
.PHONY: website
website:
@echo "==> Downloading latest Docker image..."
@docker pull $(DOCKER_IMAGE)
@$(DOCKER_CMD) pull $(DOCKER_IMAGE)
@echo "==> Starting website..."
@docker run $(DOCKER_RUN_FLAGS) $(DOCKER_IMAGE)
@$(DOCKER_CMD) run $(DOCKER_RUN_FLAGS) $(DOCKER_IMAGE)

# Use this if you have run `website/build-local` to use the locally built image.
.PHONY: website/local
website/local:
@echo "==> Starting website from local image..."
@docker run $(DOCKER_RUN_FLAGS) $(DOCKER_IMAGE_LOCAL)
@$(DOCKER_CMD) run $(DOCKER_RUN_FLAGS) $(DOCKER_IMAGE_LOCAL)

# Run this to generate a new local Docker image.
.PHONY: website/build-local
website/build-local:
@echo "==> Building local Docker image"
@docker build https://github.com/hashicorp/dev-portal.git\#main \
@$(DOCKER_CMD) build https://github.com/hashicorp/dev-portal.git\#main \
-t $(DOCKER_IMAGE_LOCAL)

5 changes: 5 additions & 0 deletions website/scripts/should-build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

######################################################
# NOTE: This file is managed by the Digital Team's #
# Terraform configuration @ hashicorp/mktg-terraform #
######################################################

# This is run during the website build step to determine if we should skip the build or not.
# More information: https://vercel.com/docs/platform/projects#ignored-build-step

Expand Down
23 changes: 22 additions & 1 deletion website/scripts/website-build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
######################################################
# NOTE: This file is managed by the Digital Team's #
# Terraform configuration @ hashicorp/mktg-terraform #
######################################################

# Repo which we are cloning and executing npm run build:deploy-preview within
REPO_TO_CLONE=dev-portal
# Set the subdirectory name for the base project
Expand All @@ -6,6 +11,15 @@ PREVIEW_DIR=website-preview
CLONE_DIR=website-preview
# The product for which we are building the deploy preview
PRODUCT=nomad
# Preview mode, controls the UI rendered (either the product site or developer). Can be `io` or `developer`
PREVIEW_MODE=developer

# Get the git branch of the commit that triggered the deploy preview
# This will power remote image assets in local and deploy previews
CURRENT_GIT_BRANCH=$VERCEL_GIT_COMMIT_REF

# This is where content files live, relative to the website-preview dir. If omitted, "../content" will be used
LOCAL_CONTENT_DIR=

from_cache=false

Expand All @@ -28,4 +42,11 @@ fi
cd "$PREVIEW_DIR"

# Run the build:deploy-preview start script
REPO=$PRODUCT DEV_IO=$PRODUCT IS_CONTENT_PREVIEW=true HASHI_ENV=project-preview npm run build:deploy-preview
PREVIEW_FROM_REPO=$PRODUCT \
IS_CONTENT_PREVIEW=true \
PREVIEW_MODE=$PREVIEW_MODE \
REPO=$PRODUCT \
HASHI_ENV=project-preview \
LOCAL_CONTENT_DIR=$LOCAL_CONTENT_DIR \
CURRENT_GIT_BRANCH=$CURRENT_GIT_BRANCH \
npm run build:deploy-preview
21 changes: 20 additions & 1 deletion website/scripts/website-start.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
######################################################
# NOTE: This file is managed by the Digital Team's #
# Terraform configuration @ hashicorp/mktg-terraform #
######################################################

# Repo which we are cloning and executing npm run build:deploy-preview within
REPO_TO_CLONE=dev-portal
# Set the subdirectory name for the dev-portal app
PREVIEW_DIR=website-preview
# The product for which we are building the deploy preview
PRODUCT=nomad
# Preview mode, controls the UI rendered (either the product site or developer). Can be `io` or `developer`
PREVIEW_MODE=developer

# Get the git branch of the commit that triggered the deploy preview
# This will power remote image assets in local and deploy previews
CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

# This is where content files live, relative to the website-preview dir. If omitted, "../content" will be used
LOCAL_CONTENT_DIR=

should_pull=true

Expand All @@ -22,4 +36,9 @@ if [ "$should_pull" = true ]; then
fi

# Run the dev-portal content-repo start script
REPO=$PRODUCT PREVIEW_DIR="$PREVIEW_DIR" npm run start:local-preview
REPO=$PRODUCT \
PREVIEW_FROM_REPO=$PRODUCT \
LOCAL_CONTENT_DIR=$LOCAL_CONTENT_DIR \
CURRENT_GIT_BRANCH=$CURRENT_GIT_BRANCH \
PREVIEW_MODE=$PREVIEW_MODE \
npm run start:local-preview

0 comments on commit bcc7f2d

Please sign in to comment.