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

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
philwinder committed Aug 10, 2016
1 parent b831cdd commit 7cc24f5
Show file tree
Hide file tree
Showing 47 changed files with 1,876 additions and 1 deletion.
116 changes: 116 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Logs
logs
*.log
npm-debug.log*

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

### Go template
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof
### Java template
/target/
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### OSX template
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea

## File-based project format:
*.iws
*.iml

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Created by .ignore support plugin (hsz.mobi)

# Maven builds
*/target
*/*/target

# AWS ECS install scripts generates an SSH key file
weave-ecs-demo-key.pem

# Load test generates pyc files
*.pyc

# Ignore Vagrant cache files
*.vagrant/
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: java
sudo: required
services:
- docker
jdk:
- oraclejdk8
install: true

env:
- GROUP=weaveworksdemos COMMIT=$TRAVIS_COMMIT TAG=$TRAVIS_TAG;

script:
- set -e
- ./scripts/build.sh;
- ./test/test.sh unit.py
- ./test/test.sh component.py
# - ./test/test.sh container.py --tag $TAG

after_success:
- set -e;
- ./test/test.sh coveralls.py
- if [ -z "$DOCKER_PASS" ] ; then
echo "This is a build triggered by an external PR. Skipping docker push.";
exit 0;
fi;
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS;
- ./scripts/push.sh
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM java:openjdk-8-alpine

WORKDIR /usr/src/app
COPY ./target/*.jar ./app.jar

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/urandom","-jar","./app.jar", "--port=80"]
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# cart
Carts service for microservices-demo application
A microservices-demo service that provides user account information.

This build is built, tested and released by travis.

# Test
`./test/test.sh < python testing file >`. For example: `./test/test.sh unit.py`

# Build
`GROUP=weaveworksdemos COMMIT=test ./scripts/build.sh`

# Push
`GROUP=weaveworksdemos COMMIT=test ./scripts/push.sh`
6 changes: 6 additions & 0 deletions docker/cart/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM java:openjdk-8-alpine

WORKDIR /usr/src/app
COPY *.jar ./app.jar

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/urandom","-jar","./app.jar", "--port=80"]
131 changes: 131 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>works.weave.microservices-demo</groupId>
<artifactId>carts</artifactId>
<packaging>jar</packaging>

<name>carts</name>
<description>Carts service for microservices-demo application</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>1.50.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.openpojo</groupId>
<artifactId>openpojo</artifactId>
<version>0.8.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>carts</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<includes>
<include>**/Unit*.java</include>
</includes>
<excludes>
<exclude>**/IT*.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<includes>
<include>**/IT*.java</include>
</includes>
<excludes>
<exclude>**/Unit*.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.2.0</version>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
31 changes: 31 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

set -ev

SCRIPT_DIR=$(dirname "$0")

if [[ -z "$GROUP" ]] ; then
echo "Cannot find GROUP env var"
exit 1
fi

if [[ -z "$COMMIT" ]] ; then
echo "Cannot find COMMIT env var"
exit 1
fi

if [[ "$(uname)" == "Darwin" ]]; then
DOCKER_CMD=docker
else
DOCKER_CMD="sudo docker"
fi
CODE_DIR=$(cd $SCRIPT_DIR/..; pwd)
echo $CODE_DIR
$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

cp $CODE_DIR/target/*.jar $CODE_DIR/docker/cart

for m in ./docker/*/; do
REPO=${GROUP}/$(basename $m)
$DOCKER_CMD build -t ${REPO}:${COMMIT} $CODE_DIR/$m;
done;
55 changes: 55 additions & 0 deletions scripts/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

set -ev

if [[ -z "$GROUP" ]] ; then
echo "Cannot find GROUP env var"
exit 1
fi

if [[ -z "$COMMIT" ]] ; then
echo "Cannot find COMMIT env var"
exit 1
fi

push() {
DOCKER_PUSH=1;
while [ $DOCKER_PUSH -gt 0 ] ; do
echo "Pushing $1";
docker push $1;
DOCKER_PUSH=$(echo $?);
if [[ "$DOCKER_PUSH" -gt 0 ]] ; then
echo "Docker push failed with exit code $DOCKER_PUSH";
fi;
done;
}

tag_and_push_all() {
if [[ -z "$1" ]] ; then
echo "Please pass the tag"
exit 1
else
TAG=$1
fi
for m in ./docker/*/; do
REPO=${GROUP}/$(basename $m)
if [[ "$COMMIT" != "$TAG" ]]; then
docker tag ${REPO}:${COMMIT} ${REPO}:${TAG}
fi
push "$REPO:$TAG";
done;
}

# Always push commit
tag_and_push_all $COMMIT

# Push snapshot when in master
if [ "$TRAVIS_BRANCH" == "master" ]; then
tag_and_push_all snapshot
fi;

# Push tag and latest when tagged
if [ -n "$TRAVIS_TAG" ]; then
tag_and_push_all ${TRAVIS_TAG}
tag_and_push_all latest
fi;
Loading

0 comments on commit 7cc24f5

Please sign in to comment.