Files

61 lines
2.0 KiB
Makefile
Raw Permalink Normal View History

2022-10-05 10:33:00 -04:00
######################################################
# NOTE: This file is managed by the Digital Team's #
# Terraform configuration @ hashicorp/mktg-terraform #
######################################################
.DEFAULT_GOAL := website
2022-10-05 10:33:00 -04:00
# Set the preview mode for the website shell to "developer" or "io"
2022-10-24 13:46:25 -05:00
PREVIEW_MODE ?= developer
2022-10-05 10:33:00 -04:00
REPO ?= packer
# Enable setting alternate docker tool, e.g. 'make DOCKER_CMD=podman'
DOCKER_CMD ?= docker
2022-10-14 17:30:59 -05:00
CURRENT_GIT_BRANCH=$$(git rev-parse --abbrev-ref HEAD)
LOCAL_CONTENT_DIR=
PWD=$$(pwd)
2022-10-14 17:30:59 -05:00
DOCKER_IMAGE="hashicorp/dev-portal"
DOCKER_IMAGE_LOCAL="dev-portal-local"
DOCKER_RUN_FLAGS=-it \
--publish "3000:3000" \
--rm \
--tty \
--volume "$(PWD)/content:/app/content" \
--volume "$(PWD)/public:/app/public" \
--volume "$(PWD)/data:/app/data" \
--volume "$(PWD)/redirects.js:/app/redirects.js" \
--volume "next-dir:/app/website-preview/.next" \
--volume "$(PWD)/.env:/app/.env" \
2022-12-05 11:53:10 -05:00
--volume "$(PWD)/.env.development:/app/website-preview/.env.development" \
--volume "$(PWD)/.env.local:/app/website-preview/.env.local" \
2022-10-05 10:33:00 -04:00
-e "REPO=$(REPO)" \
2022-10-14 17:30:59 -05:00
-e "PREVIEW_FROM_REPO=$(REPO)" \
-e "IS_CONTENT_PREVIEW=true" \
-e "LOCAL_CONTENT_DIR=$(LOCAL_CONTENT_DIR)" \
-e "CURRENT_GIT_BRANCH=$(CURRENT_GIT_BRANCH)" \
2022-10-05 10:33:00 -04:00
-e "PREVIEW_MODE=$(PREVIEW_MODE)"
2022-10-05 10:33:00 -04:00
# Default: run this if working on the website locally to run in watch mode.
.PHONY: website
2020-03-18 18:46:47 -04:00
website:
@echo "==> Downloading latest Docker image..."
2022-10-05 10:33:00 -04:00
@$(DOCKER_CMD) pull $(DOCKER_IMAGE)
@echo "==> Starting website..."
2022-10-05 10:33:00 -04:00
@$(DOCKER_CMD) run $(DOCKER_RUN_FLAGS) $(DOCKER_IMAGE)
2015-07-06 14:53:17 -06:00
2022-10-05 10:33:00 -04:00
# 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..."
2022-10-05 10:33:00 -04:00
@$(DOCKER_CMD) run $(DOCKER_RUN_FLAGS) $(DOCKER_IMAGE_LOCAL)
2020-03-18 18:46:47 -04:00
2022-10-05 10:33:00 -04:00
# Run this to generate a new local Docker image.
.PHONY: website/build-local
website/build-local:
@echo "==> Building local Docker image"
2022-10-05 10:33:00 -04:00
@$(DOCKER_CMD) build https://github.com/hashicorp/dev-portal.git\#main \
-t $(DOCKER_IMAGE_LOCAL)
2022-10-05 10:33:00 -04:00