Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update release docs and targets #388

Merged
merged 2 commits into from
Jan 31, 2024
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
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ client/build/
target/
.github/
.ebextensions/
.elasticbeanstalk/
.elasticbeanstalk/
pom.xml
45 changes: 26 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ WB_ACC_NUM := 357210185381
ECR_URI := ${WB_ACC_NUM}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com
ECR_REPO_URI := ${ECR_URI}/${ECR_REPO_NAME}
ECR_IMAGE_URI = ${ECR_REPO_URI}:${VERSION_TAG}
# Set AWS (EB) profile env vars if undefined
ifneq (${AWS_PROFILE},)
AWS_EB_PROFILE ?= ${AWS_PROFILE}
endif

# Define AWS (EB) CLI base commands as appropriate
AWS_CLI_BASE := aws
EB_CLI_BASE := eb
ifneq (${AWS_EB_PROFILE},)
AWS_PROFILE ?= ${AWS_EB_PROFILE}
EB_CLI_BASE := ${EB_CLI_BASE} --profile ${AWS_EB_PROFILE}
ifeq (${AWS_PROFILE},)
AWS_CLI_BASE := ${AWS_CLI_BASE} --profile ${AWS_EB_PROFILE}
endif
endif

export AWS_EB_PROFILE
ifneq (${AWS_PROFILE},)
AWS_CLI_BASE := ${AWS_CLI_BASE} --profile ${AWS_PROFILE}
ifeq (${AWS_EB_PROFILE},)
EB_CLI_BASE := ${EB_CLI_BASE} --profile ${AWS_PROFILE}
endif
endif

define target-help
Expand Down Expand Up @@ -93,7 +101,7 @@ build/:

build/datomic-pro-1.0.6165.zip:
@echo "Downloading datomic bundle from S3."
@aws s3 cp s3://wormbase/datomic-pro/distro/datomic-pro-1.0.6165.zip build/
@${AWS_CLI_BASE} s3 cp s3://wormbase/datomic-pro/distro/datomic-pro-1.0.6165.zip build/

.PHONY: build-docker-image
build-docker-image: build/ ENV.VERSION_TAG ${STORE_SECRETS_FILE} build/datomic-pro-1.0.6165.zip \
Expand Down Expand Up @@ -137,7 +145,7 @@ build-local: clean build-ui build-app-jar \
docker-ecr-login: \
$(call print-help,docker-ecr-login [AWS_PROFILE=<profile_name>],\
Login to ECR.)
aws --profile ${AWS_PROFILE} ecr get-login-password | docker login -u AWS --password-stdin https://${ECR_URI}
${AWS_CLI_BASE} ecr get-login-password | docker login -u AWS --password-stdin https://${ECR_URI}

.PHONY: docker-push-ecr
docker-push-ecr: docker-ecr-login \
Expand Down Expand Up @@ -177,12 +185,12 @@ eb-create: eb-def-app-env \
[GOOGLE_REDIRECT_URI=<google-redirect-uri>],\
Create an ElasticBeanStalk environment using the Docker platform.)
$(eval AWS_IAM_UNAME ?= $(shell test ${AWS_IAM_UNAME} && echo ${AWS_IAM_UNAME}\
|| aws --profile ${AWS_PROFILE} iam get-user --query "User.UserName"))
|| ${AWS_CLI_BASE} iam get-user --query "User.UserName"))
@test ${AWS_IAM_UNAME} || (\
echo "Failed to retrieve IAM user-name. Define IAM username as AWS_IAM_UNAME arg." \
&& exit 1 \
)
@eb create ${PROJ_NAME} \
@${EB_CLI_BASE} create ${PROJ_NAME} \
--region=${AWS_DEFAULT_REGION} \
--tags="CreatedBy=${AWS_IAM_UNAME},Role=RestAPI" \
--cname="${PROJ_NAME}" \
Expand All @@ -194,17 +202,17 @@ eb-create: eb-def-app-env \
.PHONY: eb-deploy
eb-deploy: eb-def-app-env \
$(call print-help,eb-deploy [PROJ_NAME=<eb-env-name>] \
[AWS_EB_PROFILE=<profile_name>] [WB_DB_URI=<datomic-db-uri>] \
[AWS(_EB)?_PROFILE=<profile_name>] [WB_DB_URI=<datomic-db-uri>] \
[GOOGLE_REDIRECT_URI=<google-redirect-uri>],\
Deploy the application using ElasticBeanstalk.)
@eb deploy ${PROJ_NAME}
@${EB_CLI_BASE} deploy ${PROJ_NAME}

.PHONY: eb-env
eb-setenv: \
$(call print-help,eb-env [AWS_EB_PROFILE=<profile_name>] [PROJ_NAME=<eb-env-name>] \
$(call print-help,eb-env [AWS(_EB)_PROFILE=<profile_name>] [PROJ_NAME=<eb-env-name>] \
[WB_DB_URI=<datomic-uri>] [GOOGLE_REDIRECT_URI=<google-redirect-uri>],\
Set enviroment variables for the ElasticBeanStalk environment.)
@eb setenv \
@${EB_CLI_BASE} setenv \
WB_DB_URI="${WB_DB_URI}" \
GOOGLE_REDIRECT_URI="${GOOGLE_REDIRECT_URI}" \
_JAVA_OPTIONS="-Xmx14g" \
Expand All @@ -215,10 +223,10 @@ eb-setenv: \

.PHONY: eb-local
eb-local: docker-ecr-login \
$(call print-help,eb-local [AWS_EB_PROFILE=<profile_name>] [PORT=<port>] \
$(call print-help,eb-local [AWS(_EB)_PROFILE=<profile_name>] [PORT=<port>] \
[WB_DB_URI=<datomic-uri>] [GOOGLE_REDIRECT_URI=<google-redirect-uri>],\
Runs the ElasticBeanStalk/docker build and run locally.)
@eb local run --envvars PORT=${PORT},WB_DB_URI=${WB_DB_URI},GOOGLE_REDIRECT_URI=${GOOGLE_REDIRECT_URI}
@${EB_CLI_BASE} local run --envvars PORT=${PORT},WB_DB_URI=${WB_DB_URI},GOOGLE_REDIRECT_URI=${GOOGLE_REDIRECT_URI}

#Note: the run-docker command can currently only be used with non-local WB_DB_URI value.
# Current setup fails to connect to local datomic DB (on host, outside of container)
Expand Down Expand Up @@ -281,7 +289,6 @@ vc-release: ENV.VERSION_TAG \
$(call print-help,vc-release LEVEL=<major|minor|patch>,\
Perform the Version Control tasks to release the applicaton.)
clj -A:release --without-sign ${LEVEL}
@echo "Edit version of application in pom.xml to match wormbase-names-* version reported above (version number only)."


.PHONY: release
Expand Down Expand Up @@ -326,7 +333,7 @@ ENV.GOOGLE_OAUTH_CLIENT_ID: source-secrets \
Retrieve the GOOGLE_OAUTH_CLIENT_ID env variable for make targets from aws ssm if undefined.)
$(eval ACTION_MSG := $(if ${GOOGLE_OAUTH_CLIENT_ID},"Using predefined GOOGLE_OAUTH_CLIENT_ID.","Retrieving GOOGLE_OAUTH_CLIENT_ID from AWS SSM (APP_PROFILE '${APP_PROFILE}')."))
@echo ${ACTION_MSG}
$(if ${GOOGLE_OAUTH_CLIENT_ID},,$(eval GOOGLE_OAUTH_CLIENT_ID := $(shell aws ssm get-parameter --name "/name-service/${APP_PROFILE}/google-oauth2-app-config/client-id" --query "Parameter.Value" --output text --with-decryption)))
$(if ${GOOGLE_OAUTH_CLIENT_ID},,$(eval GOOGLE_OAUTH_CLIENT_ID := $(shell ${AWS_CLI_BASE} ssm get-parameter --name "/name-service/${APP_PROFILE}/google-oauth2-app-config/client-id" --query "Parameter.Value" --output text --with-decryption)))
$(call check_defined, GOOGLE_OAUTH_CLIENT_ID, Check the defined APP_PROFILE value\
and ensure the AWS_PROFILE variable is appropriately defined)

Expand All @@ -336,7 +343,7 @@ ENV.GOOGLE_OAUTH_CLIENT_SECRET: source-secrets \
Retrieve the GOOGLE_OAUTH_CLIENT_SECRET env variable for make targets from aws ssm if undefined.)
$(eval ACTION_MSG := $(if ${GOOGLE_OAUTH_CLIENT_SECRET},"Using predefined GOOGLE_OAUTH_CLIENT_SECRET.","Retrieving GOOGLE_OAUTH_CLIENT_SECRET from AWS SSM (APP_PROFILE '${APP_PROFILE}')."))
@echo ${ACTION_MSG}
$(if ${GOOGLE_OAUTH_CLIENT_SECRET},,$(eval GOOGLE_OAUTH_CLIENT_SECRET := $(shell aws ssm get-parameter --name "/name-service/${APP_PROFILE}/google-oauth2-app-config/client-secret" --query "Parameter.Value" --output text --with-decryption)))
$(if ${GOOGLE_OAUTH_CLIENT_SECRET},,$(eval GOOGLE_OAUTH_CLIENT_SECRET := $(shell ${AWS_CLI_BASE} ssm get-parameter --name "/name-service/${APP_PROFILE}/google-oauth2-app-config/client-secret" --query "Parameter.Value" --output text --with-decryption)))
$(call check_defined, GOOGLE_OAUTH_CLIENT_SECRET, Check the defined APP_PROFILE value\
and ensure the AWS_PROFILE variable is appropriately defined)

Expand Down
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,6 @@ make help
To deploy an update for the main application, change your working dir
to the repository root dir and execute the following commands (bash):
```bash
# Build the client application to ensure no errors occur.
make build-ui APP_PROFILE=prod

# Generate the pom.xml file (not version-controlled)
# to ensure no errors occur (in API code)
rm pom.xml
clj -Spom

# Specify $LEVEL as one of <major|minor|patch>.
# This will bump the x, y or z version number.
# SLF4J messages can be ignored (warnings, not errors).
Expand All @@ -318,12 +310,6 @@ make show-version
# Once confirmed to be correct, push the created tag to github
git push --follow-tags

# Update the pom.xml to
# * match the version reported by make as <version> tag value
# * have "wormbase" (unquoted) as <groupId> tag value
# * have "names" (unquoted) as <artifactId> tag value
$EDITOR pom.xml

# Before building the application, ensure docker (daemon) is running.
# If not, start it. On Ubuntu you can do so with the following cmd:
sudo service docker start
Expand All @@ -343,7 +329,7 @@ make release [AWS_PROFILE=<profile_name>] APP_PROFILE=prod
# * Ensure to define the correct GOOGLE_REDIRECT_URI for google authentication (http://lvh.me:3000 when developing locally)
# Executing this make target will automatically set the required execution environment variables
# for Google Oauth2 authentication, through EB (retrieved from AWS SSM).
make eb-deploy PROJ_NAME=<env-name> [GOOGLE_REDIRECT_URI=<google-redirect-uri>] [WB_DB_URI=<datomic-db-uri>] [AWS_EB_PROFILE=<profile_name>]
make eb-deploy PROJ_NAME=<env-name> [GOOGLE_REDIRECT_URI=<google-redirect-uri>] [WB_DB_URI=<datomic-db-uri>] [AWS(_EB)?_PROFILE=<profile_name>]
```

### Deploying the IDs library
Expand Down