From c3b04aa41f9deb582545a08f758d22f45178d5b6 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Tue, 4 Jun 2019 23:45:04 -0700 Subject: [PATCH 1/2] Adding a auto build for SAS --- Dockerfile | 9 +++++++++ pom.xml | 21 +++++++++++++++++++++ runDocker.sh | 3 +++ 3 files changed, 33 insertions(+) create mode 100644 Dockerfile create mode 100755 runDocker.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..64d3ac5a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM maven:3.6.1-jdk-8 + +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app +ADD . /usr/src/app +RUN rm -rf data +RUN mvn package + +CMD ["java", "-jar", "target/dependency/jetty-runner.jar", "target/simpleAnnotationStore.war"] diff --git a/pom.xml b/pom.xml index 995d3f34..2e161238 100644 --- a/pom.xml +++ b/pom.xml @@ -170,6 +170,27 @@ 1.8 + + org.apache.maven.plugins + maven-dependency-plugin + 2.3 + + + package + copy + + + + org.mortbay.jetty + jetty-runner + 7.5.4.v20111024 + jetty-runner.jar + + + + + + diff --git a/runDocker.sh b/runDocker.sh new file mode 100755 index 00000000..67533367 --- /dev/null +++ b/runDocker.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build --rm -t sas:latest . && docker run -v /tmp/data:/usr/src/app/data --rm -p 8888:8080 --name sas sas:latest From 2c2001304f1d63790d6da98cb835b43f7ce64987 Mon Sep 17 00:00:00 2001 From: Glen Robson Date: Tue, 4 Jun 2019 23:52:20 -0700 Subject: [PATCH 2/2] Configuring AWS deploy --- buildspec.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 buildspec.yml diff --git a/buildspec.yml b/buildspec.yml new file mode 100644 index 00000000..7fd44a39 --- /dev/null +++ b/buildspec.yml @@ -0,0 +1,33 @@ +version: 0.2 + +phases: + install: + runtime-versions: + docker: 18 + commands: + - nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay& + - timeout 15 sh -c "until docker info; do echo .; sleep 1; done" + pre_build: + commands: + - echo Logging in to Amazon ECR... + - aws --version + - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) + - IMAGE_NAME="SAS" + - REPOSITORY_URI=082101253860.dkr.ecr.eu-west-2.amazonaws.com/simple_annotation_server + - IMAGE_TAG=prod_$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) + build: + commands: + - echo Build started on `date` + - echo Building the Docker image... + - echo Image_tag $IMAGE_TAG + - docker build -t $REPOSITORY_URI:latest . + - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG + post_build: + commands: + - echo Build completed on `date` + - echo Pushing the Docker images... + - docker push $REPOSITORY_URI:$IMAGE_TAG + - echo Writing image definitions file... + - printf '[{"name":"eventsContainer","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json +artifacts: + files: imagedefinitions.json