Skip to content

Commit

Permalink
support docker quick start
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodyiam committed Oct 7, 2017
1 parent 5506100 commit 6391669
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Dockerfile for apollo quick start
# Build with:
# docker build -t apollo-quick-start .
# Run with:
# docker-compose up

FROM openjdk:8-jre-alpine
MAINTAINER nobodyiam<https://github.com/nobodyiam>

COPY apollo-all-in-one.jar /apollo-quick-start/apollo-all-in-one.jar
COPY client /apollo-quick-start/client
COPY demo.sh /apollo-quick-start/demo.sh
COPY portal/apollo-portal.conf /apollo-quick-start/portal/apollo-portal.conf
COPY service/apollo-service.conf /apollo-quick-start/service/apollo-service.conf

EXPOSE 8070 8080

RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.6/community" >> /etc/apk/repositories \
&& apk update upgrade \
&& apk add --no-cache curl bash \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& sed -i'.bak' '/db_url/s/localhost/db/g' /apollo-quick-start/demo.sh \
&& sed -i "s/exit 0;/tail -f \/dev\/null/g" /apollo-quick-start/demo.sh

CMD ["/apollo-quick-start/demo.sh", "start"]
6 changes: 4 additions & 2 deletions demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ PORTAL_LOG=$PORTAL_DIR/apollo-portal.log
CLIENT_DIR=./client
CLIENT_JAR=$CLIENT_DIR/apollo-demo.jar

# go to script directory
cd "${0%/*}"

function checkJava {
if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
if [ "$windows" == "1" ]; then
Expand Down Expand Up @@ -180,7 +183,7 @@ elif [ "$1" = "client" ] ; then
else
java -classpath $CLIENT_DIR:$CLIENT_JAR $BASE_JAVA_OPTS SimpleApolloConfigDemo
fi
exit 0;

elif [ "$1" = "stop" ] ; then
echo "==== stopping portal ===="
cd $PORTAL_DIR
Expand All @@ -192,7 +195,6 @@ elif [ "$1" = "stop" ] ; then
cd $SERVICE_DIR
./$SERVICE_JAR_NAME stop

exit 0;
else
echo "Usage: demo.sh ( commands ... )"
echo "commands:"
Expand Down
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '2'

services:
apollo-quick-start:
image: apollo-quick-start
container_name: apollo-quick-start
depends_on:
- db
ports:
- "8080:8080"
- "8070:8070"
volumes:
- /tmp/logs:/opt/logs
links:
- db

db:
image: mysql:5.7
container_name: db
environment:
TZ: Asia/Shanghai
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
depends_on:
- dbdata
ports:
- "13306:3306"
volumes:
- ./sql:/docker-entrypoint-initdb.d
volumes_from:
- dbdata

dbdata:
image: alpine:latest
container_name: dbdata
volumes:
- /var/lib/mysql

0 comments on commit 6391669

Please sign in to comment.