Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Feature/waypoint poc #152

Merged
merged 3 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ GOMPLATE ?= $(DOCKER) run \
-e AWS_PROFILE="$(AWS_PROFILE)" \
-e AWS_REGION="$(AWS_REGION)" \
-e NAMESPACE="$(NAMESPACE)" \
-e ROOT_DIR="$(ROOT_DIR)" \
-e EC2_KEY_PAIR_NAME="$(EC2_KEY_PAIR_NAME)" \
-e TAG="$(TAG)" \
-e SSH_PUBLIC_KEY="$(SSH_PUBLIC_KEY)" \
Expand Down
79 changes: 79 additions & 0 deletions waypoint/main.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Macroses
########################################################################################################################

WAYPOINT ?= $(DOCKER) run \
--user "root":"$(CURRENT_USERGROUP_ID)" \
--rm \
--hostname="$(USER)-icmk-waypoint" \
-v "$(ENV_DIR)":"$(ENV_DIR)" \
-v "$(INFRA_DIR)":"$(INFRA_DIR)" \
-v "$(ROOT_DIR)":"$(ROOT_DIR)" \
-v "$(HOME)/.aws/":"/home/waypoint/.aws:ro" \
-v "$(HOME)/.aws/":"/root/.aws:ro" \
-v "/var/run/docker.sock":"/var/run/docker.sock" \
-w "$(ENV_DIR)" \
-e AWS_PROFILE="$(AWS_PROFILE)" \
-e ROOT_DIR="$(ROOT_DIR)" \
-e ENV="$(ENV)" \
$(WAYPOINT_DOCKER_IMAGE):$(WAYPOINT_VERSION)

CMD_WAYPOINT_SERVICE_BUILD ?= \
@\
cd $(ENV_DIR) && \
cat $(WAYPOINT_CONFIG_FILE).gotpl | $(GOMPLATE) > $(WAYPOINT_CONFIG_FILE) && \
$(WAYPOINT) build -app $(SVC)

CMD_WAYPOINT_SERVICE_DEPLOY ?= \
@\
cd $(ENV_DIR) && \
cat $(WAYPOINT_CONFIG_FILE).gotpl | $(GOMPLATE) > $(WAYPOINT_CONFIG_FILE) && \
$(WAYPOINT) deploy -release=false -app $(SVC)

CMD_WAYPOINT_SERVICE_RELEASE ?= \
@\
cd $(ENV_DIR) && \
cat $(WAYPOINT_CONFIG_FILE).gotpl | $(GOMPLATE) > $(WAYPOINT_CONFIG_FILE) && \
$(WAYPOINT) release -app $(SVC)

CMD_WAYPOINT_INIT ?= \
@\
cd $(ENV_DIR) && \
cat $(WAYPOINT_CONFIG_FILE).gotpl | $(GOMPLATE) > $(WAYPOINT_CONFIG_FILE) && \
$(WAYPOINT) init

CMD_WAYPOINT_INSTALL ?= \
@\
cd $(ENV_DIR) && \
cat $(WAYPOINT_CONFIG_FILE).gotpl | $(GOMPLATE) > $(WAYPOINT_CONFIG_FILE) && \
$(WAYPOINT) install -accept-tos -platform=ecs -ecs-cluster=$(WAYPOINT_ECS_CLUSTER_NAME) -ecs-region=$(AWS_REGION) -runner=$(WAYPOINT_RUNNER_ENABLED) -ecs-server-image=$(WAYPOINT_DOCKER_IMAGE):$(WAYPOINT_VERSION)

CMD_WAYPOINT_DESTROY ?= \
@\
cd $(ENV_DIR) && \
cat $(WAYPOINT_CONFIG_FILE).gotpl | $(GOMPLATE) > $(WAYPOINT_CONFIG_FILE) && \
$(WAYPOINT) destroy -auto-approve

CMD_WAYPOINT_CONFIG_SET ?= @$(WAYPOINT) config source-set --type=aws-ssm --config region=$(AWS_REGION)
# Tasks
########################################################################################################################
waypoint: waypoint.install waypoint.init
waypoint.config:
$(CMD_WAYPOINT_CONFIG_SET)

waypoint.init: gomplate waypoint-dependency
$(CMD_WAYPOINT_INIT)
$(CMD_WAYPOINT_CONFIG_SET)

waypoint.install: gomplate waypoint-dependency
$(CMD_WAYPOINT_INSTALL)

waypoint.destroy: gomplate waypoint-dependency
$(CMD_WAYPOINT_DESTROY)

# Dependencies
########################################################################################################################
# Ensures terraform is installed
waypoint-dependency:
ifeq (, $(WAYPOINT))
$(error "waypoint is not installed or incorrectly configured.")
endif
8 changes: 8 additions & 0 deletions waypoint/variables.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file should contain variables used in current module
##################################################################
# main variables
WAYPOINT_VERSION ?= latest
WAYPOINT_DOCKER_IMAGE = hazelops/waypoint
WAYPOINT_CONFIG_FILE ?= $(ENV_DIR)/waypoint.hcl
WAYPOINT_ECS_CLUSTER_NAME ?= $(ENV)-$(NAMESPACE)-waypoint
WAYPOINT_RUNNER_ENABLED ?= false