Skip to content

Commit 8add7ba

Browse files
authored
Merge pull request #50 from glenrobson/deploy-docker
Adding an auto build for SAS
2 parents 16f57ba + 2c20013 commit 8add7ba

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM maven:3.6.1-jdk-8
2+
3+
RUN mkdir -p /usr/src/app
4+
WORKDIR /usr/src/app
5+
ADD . /usr/src/app
6+
RUN rm -rf data
7+
RUN mvn package
8+
9+
CMD ["java", "-jar", "target/dependency/jetty-runner.jar", "target/simpleAnnotationStore.war"]

buildspec.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
docker: 18
7+
commands:
8+
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay&
9+
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
10+
pre_build:
11+
commands:
12+
- echo Logging in to Amazon ECR...
13+
- aws --version
14+
- $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
15+
- IMAGE_NAME="SAS"
16+
- REPOSITORY_URI=082101253860.dkr.ecr.eu-west-2.amazonaws.com/simple_annotation_server
17+
- IMAGE_TAG=prod_$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
18+
build:
19+
commands:
20+
- echo Build started on `date`
21+
- echo Building the Docker image...
22+
- echo Image_tag $IMAGE_TAG
23+
- docker build -t $REPOSITORY_URI:latest .
24+
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
25+
post_build:
26+
commands:
27+
- echo Build completed on `date`
28+
- echo Pushing the Docker images...
29+
- docker push $REPOSITORY_URI:$IMAGE_TAG
30+
- echo Writing image definitions file...
31+
- printf '[{"name":"eventsContainer","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
32+
artifacts:
33+
files: imagedefinitions.json

pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,27 @@
170170
<target>1.8</target>
171171
</configuration>
172172
</plugin>
173+
<plugin>
174+
<groupId>org.apache.maven.plugins</groupId>
175+
<artifactId>maven-dependency-plugin</artifactId>
176+
<version>2.3</version>
177+
<executions>
178+
<execution>
179+
<phase>package</phase>
180+
<goals><goal>copy</goal></goals>
181+
<configuration>
182+
<artifactItems>
183+
<artifactItem>
184+
<groupId>org.mortbay.jetty</groupId>
185+
<artifactId>jetty-runner</artifactId>
186+
<version>7.5.4.v20111024</version>
187+
<destFileName>jetty-runner.jar</destFileName>
188+
</artifactItem>
189+
</artifactItems>
190+
</configuration>
191+
</execution>
192+
</executions>
193+
</plugin>
173194
</plugins>
174195
</build>
175196
</project>

runDocker.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker build --rm -t sas:latest . && docker run -v /tmp/data:/usr/src/app/data --rm -p 8888:8080 --name sas sas:latest

0 commit comments

Comments
 (0)