Skip to content
This repository was archived by the owner on Dec 5, 2023. It is now read-only.

Commit 7cc24f5

Browse files
committed
Initial commit
1 parent b831cdd commit 7cc24f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1876
-1
lines changed

.gitignore

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Dependency directories
7+
node_modules
8+
jspm_packages
9+
10+
# Optional npm cache directory
11+
.npm
12+
13+
### Go template
14+
# Compiled Object files, Static and Dynamic libs (Shared Objects)
15+
*.o
16+
*.a
17+
*.so
18+
19+
# Folders
20+
_obj
21+
_test
22+
23+
# Architecture specific extensions/prefixes
24+
*.[568vq]
25+
[568vq].out
26+
27+
*.cgo1.go
28+
*.cgo2.c
29+
_cgo_defun.c
30+
_cgo_gotypes.go
31+
_cgo_export.*
32+
33+
_testmain.go
34+
35+
*.exe
36+
*.test
37+
*.prof
38+
### Java template
39+
/target/
40+
*.class
41+
42+
# Mobile Tools for Java (J2ME)
43+
.mtj.tmp/
44+
45+
# Package Files #
46+
*.war
47+
*.ear
48+
49+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
50+
hs_err_pid*
51+
### OSX template
52+
.DS_Store
53+
.AppleDouble
54+
.LSOverride
55+
56+
# Icon must end with two \r
57+
Icon
58+
59+
# Thumbnails
60+
._*
61+
62+
# Files that might appear in the root of a volume
63+
.DocumentRevisions-V100
64+
.fseventsd
65+
.Spotlight-V100
66+
.TemporaryItems
67+
.Trashes
68+
.VolumeIcon.icns
69+
70+
# Directories potentially created on remote AFP share
71+
.AppleDB
72+
.AppleDesktop
73+
Network Trash Folder
74+
Temporary Items
75+
.apdisk
76+
### JetBrains template
77+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
78+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
79+
80+
# User-specific stuff:
81+
.idea
82+
83+
## File-based project format:
84+
*.iws
85+
*.iml
86+
87+
## Plugin-specific files:
88+
89+
# IntelliJ
90+
/out/
91+
92+
# mpeltonen/sbt-idea plugin
93+
.idea_modules/
94+
95+
# JIRA plugin
96+
atlassian-ide-plugin.xml
97+
98+
# Crashlytics plugin (for Android Studio and IntelliJ)
99+
com_crashlytics_export_strings.xml
100+
crashlytics.properties
101+
crashlytics-build.properties
102+
fabric.properties
103+
# Created by .ignore support plugin (hsz.mobi)
104+
105+
# Maven builds
106+
*/target
107+
*/*/target
108+
109+
# AWS ECS install scripts generates an SSH key file
110+
weave-ecs-demo-key.pem
111+
112+
# Load test generates pyc files
113+
*.pyc
114+
115+
# Ignore Vagrant cache files
116+
*.vagrant/

.travis.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
language: java
2+
sudo: required
3+
services:
4+
- docker
5+
jdk:
6+
- oraclejdk8
7+
install: true
8+
9+
env:
10+
- GROUP=weaveworksdemos COMMIT=$TRAVIS_COMMIT TAG=$TRAVIS_TAG;
11+
12+
script:
13+
- set -e
14+
- ./scripts/build.sh;
15+
- ./test/test.sh unit.py
16+
- ./test/test.sh component.py
17+
# - ./test/test.sh container.py --tag $TAG
18+
19+
after_success:
20+
- set -e;
21+
- ./test/test.sh coveralls.py
22+
- if [ -z "$DOCKER_PASS" ] ; then
23+
echo "This is a build triggered by an external PR. Skipping docker push.";
24+
exit 0;
25+
fi;
26+
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS;
27+
- ./scripts/push.sh

Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM java:openjdk-8-alpine
2+
3+
WORKDIR /usr/src/app
4+
COPY ./target/*.jar ./app.jar
5+
6+
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/urandom","-jar","./app.jar", "--port=80"]

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
# cart
2-
Carts service for microservices-demo application
2+
A microservices-demo service that provides user account information.
3+
4+
This build is built, tested and released by travis.
5+
6+
# Test
7+
`./test/test.sh < python testing file >`. For example: `./test/test.sh unit.py`
8+
9+
# Build
10+
`GROUP=weaveworksdemos COMMIT=test ./scripts/build.sh`
11+
12+
# Push
13+
`GROUP=weaveworksdemos COMMIT=test ./scripts/push.sh`

docker/cart/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM java:openjdk-8-alpine
2+
3+
WORKDIR /usr/src/app
4+
COPY *.jar ./app.jar
5+
6+
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/urandom","-jar","./app.jar", "--port=80"]

pom.xml

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>works.weave.microservices-demo</groupId>
8+
<artifactId>carts</artifactId>
9+
<packaging>jar</packaging>
10+
11+
<name>carts</name>
12+
<description>Carts service for microservices-demo application</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>1.4.0.RELEASE</version>
18+
</parent>
19+
20+
<properties>
21+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22+
<java.version>1.8</java.version>
23+
</properties>
24+
25+
<dependencies>
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-data-rest</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter-data-mongodb</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.data</groupId>
36+
<artifactId>spring-data-rest-hal-browser</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter-test</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
<dependency>
44+
<groupId>de.flapdoodle.embed</groupId>
45+
<artifactId>de.flapdoodle.embed.mongo</artifactId>
46+
<version>1.50.5</version>
47+
<scope>test</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>com.openpojo</groupId>
51+
<artifactId>openpojo</artifactId>
52+
<version>0.8.4</version>
53+
<scope>test</scope>
54+
</dependency>
55+
</dependencies>
56+
57+
<build>
58+
<finalName>carts</finalName>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.springframework.boot</groupId>
62+
<artifactId>spring-boot-maven-plugin</artifactId>
63+
</plugin>
64+
<plugin>
65+
<groupId>org.apache.maven.plugins</groupId>
66+
<artifactId>maven-surefire-plugin</artifactId>
67+
<version>2.19.1</version>
68+
<configuration>
69+
<includes>
70+
<include>**/Unit*.java</include>
71+
</includes>
72+
<excludes>
73+
<exclude>**/IT*.java</exclude>
74+
</excludes>
75+
</configuration>
76+
</plugin>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-failsafe-plugin</artifactId>
80+
<version>2.18.1</version>
81+
<configuration>
82+
<includes>
83+
<include>**/IT*.java</include>
84+
</includes>
85+
<excludes>
86+
<exclude>**/Unit*.java</exclude>
87+
</excludes>
88+
</configuration>
89+
<executions>
90+
<execution>
91+
<goals>
92+
<goal>integration-test</goal>
93+
<goal>verify</goal>
94+
</goals>
95+
</execution>
96+
</executions>
97+
</plugin>
98+
<plugin>
99+
<groupId>org.jacoco</groupId>
100+
<artifactId>jacoco-maven-plugin</artifactId>
101+
<version>0.7.6.201602180812</version>
102+
<executions>
103+
<execution>
104+
<id>prepare-agent</id>
105+
<goals>
106+
<goal>prepare-agent</goal>
107+
</goals>
108+
</execution>
109+
</executions>
110+
</plugin>
111+
<plugin>
112+
<groupId>org.eluder.coveralls</groupId>
113+
<artifactId>coveralls-maven-plugin</artifactId>
114+
<version>4.2.0</version>
115+
</plugin>
116+
</plugins>
117+
</build>
118+
119+
<repositories>
120+
<repository>
121+
<id>spring-releases</id>
122+
<url>https://repo.spring.io/libs-release</url>
123+
</repository>
124+
</repositories>
125+
<pluginRepositories>
126+
<pluginRepository>
127+
<id>spring-releases</id>
128+
<url>https://repo.spring.io/libs-release</url>
129+
</pluginRepository>
130+
</pluginRepositories>
131+
</project>

scripts/build.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -ev
4+
5+
SCRIPT_DIR=$(dirname "$0")
6+
7+
if [[ -z "$GROUP" ]] ; then
8+
echo "Cannot find GROUP env var"
9+
exit 1
10+
fi
11+
12+
if [[ -z "$COMMIT" ]] ; then
13+
echo "Cannot find COMMIT env var"
14+
exit 1
15+
fi
16+
17+
if [[ "$(uname)" == "Darwin" ]]; then
18+
DOCKER_CMD=docker
19+
else
20+
DOCKER_CMD="sudo docker"
21+
fi
22+
CODE_DIR=$(cd $SCRIPT_DIR/..; pwd)
23+
echo $CODE_DIR
24+
$DOCKER_CMD run --rm -v $HOME/.m2:/root/.m2 -v $CODE_DIR:/usr/src/mymaven -w /usr/src/mymaven maven:3.2-jdk-8 mvn -DskipTests package
25+
26+
cp $CODE_DIR/target/*.jar $CODE_DIR/docker/cart
27+
28+
for m in ./docker/*/; do
29+
REPO=${GROUP}/$(basename $m)
30+
$DOCKER_CMD build -t ${REPO}:${COMMIT} $CODE_DIR/$m;
31+
done;

scripts/push.sh

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
set -ev
4+
5+
if [[ -z "$GROUP" ]] ; then
6+
echo "Cannot find GROUP env var"
7+
exit 1
8+
fi
9+
10+
if [[ -z "$COMMIT" ]] ; then
11+
echo "Cannot find COMMIT env var"
12+
exit 1
13+
fi
14+
15+
push() {
16+
DOCKER_PUSH=1;
17+
while [ $DOCKER_PUSH -gt 0 ] ; do
18+
echo "Pushing $1";
19+
docker push $1;
20+
DOCKER_PUSH=$(echo $?);
21+
if [[ "$DOCKER_PUSH" -gt 0 ]] ; then
22+
echo "Docker push failed with exit code $DOCKER_PUSH";
23+
fi;
24+
done;
25+
}
26+
27+
tag_and_push_all() {
28+
if [[ -z "$1" ]] ; then
29+
echo "Please pass the tag"
30+
exit 1
31+
else
32+
TAG=$1
33+
fi
34+
for m in ./docker/*/; do
35+
REPO=${GROUP}/$(basename $m)
36+
if [[ "$COMMIT" != "$TAG" ]]; then
37+
docker tag ${REPO}:${COMMIT} ${REPO}:${TAG}
38+
fi
39+
push "$REPO:$TAG";
40+
done;
41+
}
42+
43+
# Always push commit
44+
tag_and_push_all $COMMIT
45+
46+
# Push snapshot when in master
47+
if [ "$TRAVIS_BRANCH" == "master" ]; then
48+
tag_and_push_all snapshot
49+
fi;
50+
51+
# Push tag and latest when tagged
52+
if [ -n "$TRAVIS_TAG" ]; then
53+
tag_and_push_all ${TRAVIS_TAG}
54+
tag_and_push_all latest
55+
fi;

0 commit comments

Comments
 (0)