-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
248 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
DOCKER_USER_HOME=/home/user | ||
CACHED_VOLUMES="m2 groovy grails gradle" | ||
|
||
function get_cached_volumes { | ||
volumes_str="" | ||
for v in $CACHED_VOLUMES; do | ||
volumes_str+="-v $HOME/.$v:$DOCKER_USER_HOME/.$v " | ||
done | ||
echo $volumes_str | ||
} | ||
|
||
docker run -it --rm \ | ||
-v `pwd`:$DOCKER_USER_HOME/work \ | ||
`get_cached_volumes` \ | ||
--entrypoint /home/user/entrypoint.sh \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
reverse-app/builder $1 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM openjdk:8u111-jdk | ||
|
||
VOLUME /tmp | ||
|
||
RUN groupadd -r user && useradd -r -g user user | ||
|
||
COPY consumer-0.1.jar /app/consumer.jar | ||
RUN bash -c 'touch /app/consumer.jar' | ||
RUN chown -R user:user /app | ||
|
||
USER user | ||
WORKDIR /app | ||
|
||
CMD ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/consumer.jar"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM openjdk:8u111-jdk | ||
|
||
# Locale setup | ||
RUN apt-get update && \ | ||
apt-get install -yq locales ca-certificates wget sudo && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 | ||
ENV LANG en_US.UTF-8 | ||
ENV LC_ALL en_US.UTF-8 | ||
|
||
# Docker | ||
RUN echo 'deb http://httpredir.debian.org/debian jessie-backports main' > /etc/apt/sources.list.d/jessie-backports.list && \ | ||
apt-get update && apt-get install -yq docker.io && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Add user | ||
RUN useradd user -d /home/user -s /bin/bash && \ | ||
cp -r /etc/skel /home/user && \ | ||
chown user.user -R /home/user && \ | ||
echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
|
||
USER user | ||
WORKDIR /home/user | ||
|
||
COPY files/entrypoint.sh /home/user/ | ||
COPY files/postgresql /home/user/postgresql | ||
COPY files/rabbitmq /home/user/rabbitmq |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker build -t reverse-app/builder . |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
function build-postgresql { | ||
echo "##########################" | ||
echo "# Building postgresql... #" | ||
echo "##########################" | ||
sudo docker build -t reverse-app/postgresql ./postgresql/ | ||
} | ||
|
||
function build-rabbitmq { | ||
echo "########################" | ||
echo "# Building rabbitmq... #" | ||
echo "########################" | ||
sudo docker build -t reverse-app/rabbitmq ./rabbitmq/ | ||
} | ||
|
||
|
||
function build-producer { | ||
echo "########################" | ||
echo "# Building producer... #" | ||
echo "########################" | ||
(cd work/producer && ./gradlew clean build prepareDocker && \ | ||
sudo docker build -t reverse-app/producer ./build/docker/) | ||
} | ||
|
||
function build-consumer { | ||
echo "########################" | ||
echo "# Building consumer... #" | ||
echo "########################" | ||
(cd work/consumer && ./gradlew clean build prepareDocker && \ | ||
sudo docker build -t reverse-app/consumer ./build/docker/) | ||
} | ||
|
||
|
||
case $1 in | ||
postgresql) | ||
build-postgresql | ||
;; | ||
rabbitmq) | ||
build-rabbitmq | ||
;; | ||
producer) | ||
build-producer | ||
;; | ||
consumer) | ||
build-consumer | ||
;; | ||
all) | ||
build-postgresql | ||
build-rabbitmq | ||
build-producer | ||
build-consumer | ||
;; | ||
*) | ||
echo "USAGE: $0 [ postgresql | rabbitmq | producer | consumer | all ]" | ||
exit 1 | ||
;; | ||
esac |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM postgres:9.4.9 | ||
|
||
VOLUME /var/lib/postgresql/data | ||
|
||
COPY ["setup.sh", "/docker-entrypoint-initdb.d/"] | ||
|
||
EXPOSE 5432 |
15 changes: 15 additions & 0 deletions
15
docker/02_docker-compose/builder/files/postgresql/setup.sh
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
echo "######### CREATING DATABASE ##########" | ||
|
||
# Perform all actions as user 'postgres' | ||
export PGUSER=postgres | ||
|
||
# Create the reverse-app user and database | ||
psql <<EOSQL | ||
CREATE DATABASE reverseapp; | ||
CREATE ROLE reverseuser WITH LOGIN PASSWORD 'reversepass'; | ||
GRANT ALL PRIVILEGES ON DATABASE reverseapp TO reverseuser; | ||
EOSQL | ||
|
||
echo "" | ||
echo "######### DATABASE CREATED ##########" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM rabbitmq:3.6.5-management | ||
|
||
RUN rabbitmq-plugins enable --offline rabbitmq_management | ||
|
||
EXPOSE 15672 |
20 changes: 20 additions & 0 deletions
20
docker/02_docker-compose/docker-compose/docker-compose.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: '2' | ||
services: | ||
postgresql: | ||
image: reverse-app/postgresql | ||
|
||
rabbitmq: | ||
image: reverse-app/rabbitmq | ||
|
||
producer: | ||
image: reverse-app/producer | ||
ports: | ||
- "8080:8080" | ||
links: | ||
- rabbitmq:rabbitmq | ||
|
||
consumer: | ||
image: reverse-app/consumer | ||
links: | ||
- rabbitmq:rabbitmq | ||
- postgresql:postgresql |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM openjdk:8u111-jdk | ||
|
||
VOLUME /tmp | ||
|
||
RUN groupadd -r user && useradd -r -g user user | ||
|
||
COPY producer-0.1.jar /app/producer.jar | ||
RUN bash -c 'touch /app/producer.jar' | ||
RUN chown -R user:user /app | ||
|
||
USER user | ||
WORKDIR /app | ||
|
||
CMD ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/producer.jar"] |