Please read this gist first: Deploying to Elastic Beanstalk via CircleCi 2.0
Here is my .elasticbeanstalk/config.yml
config:
branch-defaults:
master:
environment: myapp-env
deploy:
artifact: my-app.zip
global:
application_name: mywebapp
default_ec2_keyname: circleci-key-pair
default_platform: Docker running on 64bit Amazon Linux/2.12.17
default_region: eu-central-1
sc: git
And this is .circleci/config.yml
config:
# Clojure CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-clojure/ for more details
#
version: 2
jobs:
deploy:
docker:
# specify the version you desire here
- image: circleci/clojure:lein-2.7.1
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
environment:
LEIN_ROOT: "true"
# Customize the JVM maximum heap limit
JVM_OPTS: -Xmx3g
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "project.clj" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run:
name: Installing deployment dependencies
working_directory: /
command: |
sudo apt-get -y -qq update
sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade setuptools
sudo pip install awsebcli --upgrade
- run: echo 'export PATH=$PATH:/home/circleci/.local/bin/' >> $BASH_ENV
- run:
name: Setup AWS credentials
command: |
mkdir ~/.aws && printf "[profile eb-cli]\naws_access_key_id = ${AWS_ACCESS_KEY_ID}\naws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}" > ~/.aws/config
- run: curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash -
- run: sudo apt-get install -y nodejs
- run: npm install --silent
- run: lein deps
- run: lein ui-prod
- run: lein uberjar
- run: mv target/uberjar/my-app.jar app.jar
- run: zip my-app Dockerfile Dockerrun.aws.json app.jar
- store_artifacts:
path: my-app.zip
destination: build
- run:
name: Deploying
command: eb deploy --timeout 30
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "project.clj" }}
workflows:
version: 2
build:
jobs:
- deploy:
filters:
branches:
only:
- master
My Dockerfile
:
FROM clojure:openjdk-11-lein-2.9.1 AS lein
ADD app.jar /root/.webapp/app.jar
EXPOSE 3000
ENTRYPOINT exec java -jar \
-server \
-Xmx1250m \
-XX:+UseConcMarkSweepGC \
-XX:+CMSParallelRemarkEnabled \
-XX:+UseCMSInitiatingOccupancyOnly \
-XX:CMSInitiatingOccupancyFraction=70 \
-XX:+ScavengeBeforeFullGC \
-XX:+CMSScavengeBeforeRemark \
-Djava.net.preferIPv4Stack=true \
/root/.webapp/app.jar
And last config Dockerrun.aws.json
:
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "my-app-name",
"Update": "true"
},
"Volumes": [
{
"HostDirectory": "/var/app",
"ContainerDirectory": "/var/app"
}
],
"Logging": "/var/log/nginx"
}