Last active
December 15, 2016 22:09
-
-
Save natemurthy/7211092514a2cb6ae04411a93d9ce289 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dockerfile.tools | |
FROM ubuntu | |
RUN apt-get update && \ | |
apt-get install -y \ | |
openjdk-8-jdk \ | |
wget \ | |
curl \ | |
iputils-ping \ | |
net-tools \ | |
python | |
# Dockerfile.java-app | |
FROM openjdk:8-jdk | |
COPY . /app | |
WORKDIR /app | |
# Remove target folders | |
RUN rm -rf /app/project/project/target && \ | |
rm -rf /app/project/target && \ | |
rm -rf /app/target && \ | |
# Download SBT into container | |
RUN eval $(sed s/sbt.version/SBT_VERSION/ < /app/project/build.properties) && \ | |
mkdir -p /usr/local/bin && \ | |
wget -P /usr/local/bin/ https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/$SBT_VERSION/sbt-launch.jar && \ | |
cp /app/project/sbt /usr/local/bin && \ | |
chmod +x /usr/local/bin/sbt | |
# Docker Compose | |
version: '2' | |
services: | |
app: | |
container_name: app_${TEST_ID} | |
build: | |
context: . | |
dockerfile: Dockerfile.test | |
volumes: | |
- .:/app | |
- ./target:/app/target | |
- ~/.ivy2:/root/.ivy2 | |
- ~/.sbt:/root/.sbt2 | |
depends_on: | |
- postgres | |
- rabbitmq | |
postgres: | |
container_name: postgres_${TEST_ID} | |
build: | |
context: ./dev/containers/postgres | |
dockerfile: Dockerfile | |
rabbitmq: | |
container_name: rabbitmq_${TEST_ID} | |
build: | |
context: ./dev/containers/rabbitmq | |
dockerfile: Dockerfile | |
networks: | |
default: | |
external: | |
name: app_test_${TEST_ID} | |
# compose up script | |
PROJECT_DIR="$(cd "`dirname $0`"/..; pwd)" | |
cd $PROJECT_DIR | |
# Give test harness a unique ID so that it does not interfere | |
# with other integration tests running on the same machine | |
export TEST_ID=$(dd if=/dev/random bs=2 count=1 2>/dev/null | od -An -tx1 | tr -d ' \t\n') | |
docker network create app_test_$TEST_ID | |
docker-compose -f docker-compose.test.yml -p app up --abort-on-container-exit | |
docker-compose -f docker-compose.test.yml -p app down --rmi all | |
docker network rm app_test_$TEST_ID | |
unset TEST_ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment