diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8780628 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ + +# NOTE: This should not be used in production! +# +# biuld: +# docker build -t overwatch . +# run: +# docker run --name=overwatch-dev -p 4200:80 -p 3000:3000 -tid overwatch +# attach: +# docker exec -it overwatch-dev bash +# +# visit: http://localhost:4200 after build & run +# + +FROM node:boron-slim +MAINTAINER lidian +WORKDIR /root + +# install packages +RUN { \ + echo debconf debconf/frontend select Noninteractive; \ + echo mysql-community-server mysql-community-server/data-dir select ''; \ + echo mysql-community-server mysql-community-server/root-pass password ''; \ + echo mysql-community-server mysql-community-server/re-root-pass password ''; \ + echo mysql-community-server mysql-community-server/remove-test-db select true; \ + } | debconf-set-selections \ + && apt-get update && apt-get install -y git unzip nginx mysql-server + +# validate mysql & create database +# https://serverfault.com/a/892896 +RUN find /var/lib/mysql -type f -exec touch {} \; && \ + service mysql start && \ + echo 'create database overwatch' | mysql -uroot + +# download source +#RUN wget https://github.com/imdada/overwatch/archive/dev.zip && unzip dev.zip && mv overwatch-dev overwatch +RUN git clone https://github.com/imdada/overwatch.git + +#ADD environment.prod.ts overwatchweb/src/environments/environment.prod.ts +#ADD environment.ts overwatch/web/src/environments/environment.ts +#ADD config.json overwatch/server/app/config.json +#ADD nigix.sh /root/overwatch/nigix.sh + +# build source +WORKDIR /root/overwatch +RUN yes | sh install.sh +#RUN cd web && npm start +RUN cd web && npm run build +RUN rm -r /var/www/html/* +RUN cp -r /root/overwatch/web/dist/* /var/www/html/ +WORKDIR /root/overwatch/server +ADD entrypoint.sh /root/entrypoint.sh +EXPOSE 80 3000 +ENTRYPOINT [ "/root/entrypoint.sh" ] diff --git a/config.json b/config.json new file mode 100644 index 0000000..86bf136 --- /dev/null +++ b/config.json @@ -0,0 +1,29 @@ +{ + "https": { + "enabled": false, + "key": "", + "cert": "" + }, + "port": 3000, + "socket": { + "path": "/socket" + }, + "corsDomain": "http://127.0.0.1:4200", + "messaging": "socket", + "db": { + "uri": "mysql://root:root@127.0.0.1:3306/overwatch", + "pool": { + "max": 5, + "min": 0, + "idle": 10000 + } + }, + "redis": { + "host": "127.0.0.1", + "port": 6379 + }, + "log": { + "appenders": { "out": { "type": "stdout" } }, + "categories": { "default": { "appenders": ["out"], "level": "debug" } } + } +} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..2af4d5b --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,50 @@ +# NOTE: This should not be used in production! +# +# biuld: +# docker build -t overwatch . +# run: +# docker run --name=overwatch-dev -p 4200:80 -p 3000:3000 -tid overwatch +# attach: +# docker exec -it overwatch-dev bash +# +# visit: http://localhost:4200 after build & run +# + +FROM node:boron-slim +MAINTAINER ZstringX +WORKDIR /root + +# install packages +RUN { \ + echo debconf debconf/frontend select Noninteractive; \ + echo mysql-community-server mysql-community-server/data-dir select ''; \ + echo mysql-community-server mysql-community-server/root-pass password ''; \ + echo mysql-community-server mysql-community-server/re-root-pass password ''; \ + echo mysql-community-server mysql-community-server/remove-test-db select true; \ + } | debconf-set-selections \ + && apt-get update && apt-get install -y unzip nginx mysql-server + +# validate mysql & create database +# https://serverfault.com/a/892896 +RUN find /var/lib/mysql -type f -exec touch {} \; && \ + service mysql start && \ + echo 'create database overwatch' | mysql -uroot + +# download source +#RUN wget https://github.com/imdada/overwatch/archive/dev.zip && \ +# unzip dev.zip && rm -f dev.zip && mv overwatch-dev overwatch +RUN git clone https://github.com/imdada/overwatch.git + +# build source +WORKDIR /root/overwatch +RUN yes | sh install.sh +WORKDIR /root/overwatch/web +RUN npm run build && cp -r dist/* /var/www/html && nginx + +# clean +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +WORKDIR /root/overwatch/server +ADD entrypoint.sh /root/entrypoint.sh +EXPOSE 80 3000 +ENTRYPOINT [ "/root/entrypoint.sh" ] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..879a342 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash +find /var/lib/mysql -type f -exec touch {} \; && service mysql start +nginx +cd /root/overwatch/server && npm start diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..879a342 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash +find /var/lib/mysql -type f -exec touch {} \; && service mysql start +nginx +cd /root/overwatch/server && npm start diff --git a/environment.prod.ts b/environment.prod.ts new file mode 100644 index 0000000..77bb4a4 --- /dev/null +++ b/environment.prod.ts @@ -0,0 +1,4 @@ +export const environment = { + production: true, + apiUrl: "http://127.0.0.1:3000" +}; diff --git a/environment.ts b/environment.ts new file mode 100644 index 0000000..6d20226 --- /dev/null +++ b/environment.ts @@ -0,0 +1,9 @@ +// The file contents for the current environment will overwrite these during build. +// The build system defaults to the dev environment which uses `environment.ts`, but if you do +// `ng build --env=prod` then `environment.prod.ts` will be used instead. +// The list of which env maps to which file can be found in `.angular-cli.json`. + +export const environment = { + production: false, + apiUrl: "http://localhost:3000" +}; diff --git a/example/rest-demo.sh b/example/rest-demo.sh index 779d049..063742f 100755 --- a/example/rest-demo.sh +++ b/example/rest-demo.sh @@ -1,4 +1,4 @@ -host=localhost:3000 +host=127.0.0.1:3000 system=`uname` if [ $system = Darwin ] then diff --git a/example/system-stats.json b/example/system-stats.json index c0ab6ec..0fcad0b 100644 --- a/example/system-stats.json +++ b/example/system-stats.json @@ -1,5 +1,5 @@ { - "time": 1513047531, + "time": 1517152984, "stats": { "gateway-lb": { "service-A": { diff --git a/nigix.sh b/nigix.sh new file mode 100755 index 0000000..0cc01af --- /dev/null +++ b/nigix.sh @@ -0,0 +1,3 @@ +#!/bin/bash +nginx -s stop +nginx \ No newline at end of file