Skip to content

Commit

Permalink
Migrated Elastic Beanstalk platform to Docker on Amazon Linux 2 (from…
Browse files Browse the repository at this point in the history
… Amazon linux 1) #325
  • Loading branch information
mluypaert committed Aug 3, 2023
1 parent 95db664 commit c46ad92
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 72 deletions.
3 changes: 1 addition & 2 deletions .ebextensions/aws-autoscaling.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
option_settings:
aws:ec2:instances:
InstanceTypes: m4.large
InstanceTypes: m6i.large
aws:autoscaling:asg:
Availability Zones: Any
Cooldown: '360'
Expand All @@ -16,7 +16,6 @@ option_settings:
LowerThreshold: 10
UpperThreshold: 70
aws:autoscaling:launchconfiguration:
BlockDeviceMappings: /dev/xvdcz=:12:true:gp2
EC2KeyName: eb_wormbase_names
IamInstanceProfile: aws-elasticbeanstalk-ec2-role
MonitoringInterval: 5 minute
Expand Down
8 changes: 5 additions & 3 deletions .ebextensions/aws-ec2-vpc.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
option_settings:
aws:ec2:vpc:
AssociatePublicIpAddress: 'true'
AssociatePublicIpAddress: true
ELBScheme: public
ELBSubnets: subnet-a33a2bd5
Subnets: subnet-a33a2bd5
ELBSubnets:
- subnet-a33a2bd5
Subnets:
- subnet-a33a2bd5
VPCId: vpc-8e0087e9
9 changes: 5 additions & 4 deletions .ebextensions/cloudwatch.config
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# TODO: replace CloudWatchMonitoringScripts (deprecated) with CloudwatchAgent
packages:
yum:
perl-DateTime: []
perl-Sys-Syslog: []
perl-LWP-Protocol-https: []
perl-Switch: []
perl-URI: []
perl-Bundle-LWP: []
perl-Digest-SHA.x86_64: []

sources:
/opt/cloudwatch: http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip
/opt/cloudwatch: http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.2.zip

container_commands:
01-setupcron:
Expand All @@ -20,7 +21,7 @@ container_commands:
command: chmod u+x /opt/cloudwatch/aws-scripts-mon/mon-put-instance-data.pl

option_settings:
"aws:autoscaling:launchconfiguration" :
IamInstanceProfile : "aws-elasticbeanstalk-ec2-role"
# "aws:autoscaling:launchconfiguration" :
# IamInstanceProfile : "aws-elasticbeanstalk-ec2-role"
"aws:elasticbeanstalk:customoption" :
CloudWatchMetrics : "--mem-util --mem-used --mem-avail --disk-space-util --disk-space-used --disk-space-avail --disk-path=/ --auto-scaling"
22 changes: 6 additions & 16 deletions .ebextensions/elasticbeanstalk-environment.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,17 @@ option_settings:
DeleteOnTerminate: 'false'
RetentionInDays: '14'
StreamLogs: 'true'
aws:elasticbeanstalk:command:
BatchSize: '30'
BatchSizeType: Percentage
IgnoreHealthCheck: 'false'
Timeout: '600'
aws:elasticbeanstalk:control:
DefaultSSHPort: '22'
LaunchTimeout: '0'
LaunchType: Migration
RollbackLaunchOnFailure: 'false'
aws:elasticbeanstalk:environment:
EnvironmentType: LoadBalanced
ServiceRole: aws-elasticbeanstalk-service-role
aws:elasticbeanstalk:environment:process:default:
DeregistrationDelay: '20'
HealthCheckInterval: '15'
DeregistrationDelay: '20' #Default?
HealthCheckInterval: '15' #Default?
HealthCheckPath: '/index.html'
HealthCheckTimeout: '5'
MatcherHttpCode: '200'
Port: '80'
Protocol: HTTP
HealthCheckTimeout: '5' #Default?
MatcherHttpCode: '200' #Default?
Port: '80' #Default?
Protocol: HTTP #Default?
StickinessEnabled: 'true'
StickinessLBCookieDuration: '43200'
aws:elasticbeanstalk:hostmanager:
Expand Down
11 changes: 7 additions & 4 deletions .ebignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# The precense of this file tells the AWS EB CLI to not use git for deployment as per
# https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-deploy.html
#
.git
Dockerrun.aws.json.template
test/
*.pom

# Ignore everything
*

# but not these files
!docker-compose.yml
!.ebextensions/*
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Dockerrun.aws.json
/docker/app.jar
/.dockerignore

#Local docker-compose env-variable files
.env

# secrets
/resources/secrets/

Expand Down
13 changes: 0 additions & 13 deletions Dockerrun.aws.json.template

This file was deleted.

13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ build: clean ui-build docker/${DEPLOY_JAR} \
Build the docker images from using the current git revision.)
@docker build -t ${ECR_REPO_NAME}:${VERSION_TAG} \
--build-arg uberjar_path=${DEPLOY_JAR} \
--rm ./docker/
./docker/

.PHONY: ui-build
ui-build: \
Expand Down Expand Up @@ -114,6 +114,7 @@ ifndef WB_DB_URI
endif
@cp ebextensions-templates/${EB_APP_ENV_FILE} .ebextensions/
@sed -i -r 's~(WB_DB_URI:\s+)".*"~\1"'"${WB_DB_URI}"'"~' .ebextensions/${EB_APP_ENV_FILE}
sed -i 's/\(WB_NAMES_RELEASE: \).\+/\1'${VERSION_TAG}'/' .ebextensions/${EB_APP_ENV_FILE}

.PHONY: eb-create
eb-create: eb-def-app-env \
Expand All @@ -129,7 +130,8 @@ eb-create: eb-def-app-env \
@eb create ${PROJ_NAME} \
--region=us-east-1 \
--tags="CreatedBy=${AWS_IAM_UNAME},Role=RestAPI" \
--cname="${PROJ_NAME}"
--cname="${PROJ_NAME}" \
-p docker

.PHONY: eb-deploy
eb-deploy: eb-def-app-env \
Expand Down Expand Up @@ -184,20 +186,19 @@ deploy-ecr: docker-build docker-ecr-login docker-tag docker-push-ecr

.PHONY: vc-release
vc-release: export VERSION_TAG := ${VERSION_TAG}
vc-release: \
$(call print-help,vc-release LEVEL=<major|minor|patch>,\
vc-release: $(call print-help,vc-release LEVEL=<major|minor|patch>,\
Perform the Version Control tasks to release the applicaton.)
@echo "Edit version of application in pom.xml to match:"
@clj -A:release --without-sign ${LEVEL}
@clj -A:datomic-pro:prod:aws-eb-docker-version
@clj -A:datomic-pro:prod


.PHONY: release
release: export VERSION_TAG := ${VERSION_TAG}
release: deploy-ecr \
$(call print-help,release [AWS_PROFILE=<profile_name>] [REF_NAME=<tag-or-gitref>],\
Release the applicaton.)
@clj -A:datomic-pro:prod:aws-eb-docker-version
@clj -A:datomic-pro:prod

.PHONY: run-tests
run-tests: \
Expand Down
1 change: 0 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
:main-opts ["-m" "metav.display"]}
:release {:extra-deps {metav {:mvn/version "1.5.2"}}
:main-opts ["-m" "metav.release"]}
:aws-eb-docker-version {:main-opts ["-m" "wormbase.aws-eb-docker"]}
:event-broadcast
{:extra-deps
{com.draines/postal {:mvn/version "2.0.3"}
Expand Down
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3.2"

services:

names.service:
container_name: wb.names.service
image: 357210185381.dkr.ecr.us-east-1.amazonaws.com/wormbase/names:${WB_NAMES_RELEASE}
ports:
- "80:3000"
env_file:
- .env
3 changes: 3 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ FROM openjdk:8-jre-alpine
ARG uberjar_path=
ADD $uberjar_path /srv/app.jar

# Expose necessary ports
EXPOSE 3000

CMD ["java", "-cp", "/srv/app.jar", "clojure.main", "-m", "wormbase.names.service"]
1 change: 1 addition & 0 deletions ebextensions-templates/app-env.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
option_settings:
aws:elasticbeanstalk:application:environment:
WB_NAMES_RELEASE: 0.0.0
WB_DB_URI: ""
_JAVA_OPTIONS: "-Xmx4g"
23 changes: 0 additions & 23 deletions src/wormbase/aws_eb_docker.clj

This file was deleted.

0 comments on commit c46ad92

Please sign in to comment.