diff --git a/Web-Dockerfile b/Web-Dockerfile new file mode 100644 index 00000000..0d7319be --- /dev/null +++ b/Web-Dockerfile @@ -0,0 +1,13 @@ +FROM nginx + +# remove the config +RUN rm /etc/nginx/conf.d/default.conf && \ + rm /etc/nginx/nginx.conf && \ + mkdir -p /usr/share/nginx/web && \ + mkdir -p /usr/share/nginx/admin + +# copy the config and web codes +COPY ./nginx.conf /etc/nginx/ +COPY ./web/build/ /usr/share/nginx/web +COPY ./admin/ /usr/share/nginx/admin +CMD ['nginx', '-c /etc/nginx/nginx.conf', '-g "daemon off;"'] \ No newline at end of file diff --git a/admin/Dockerfile b/admin/Dockerfile new file mode 100644 index 00000000..ccbeba65 --- /dev/null +++ b/admin/Dockerfile @@ -0,0 +1,5 @@ +FROM nginx +WORKDIR /code + +COPY . /usr/share/nginx/html +CMD ['nginx', '-c /etc/nginx/nginx.conf', '-g "daemon off;"'] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..c6f93f91 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,54 @@ +version: '3' +services: + api: + build: ./myems-api + command: gunicorn app:api -b 0.0.0.0 + network_mode: "host" + restart: always +# ports: +# - "8000:8000" + + aggregation: + build: ./myems-aggregation + command: python main.py + network_mode: "host" + restart: always + + cleaning: + build: ./myems-cleaning + command: python main.py + network_mode: "host" + restart: always + + modbus_tcp: + build: ./myems-modbus-tcp + command: python main.py + network_mode: "host" + restart: always + + normalization: + build: ./myems-normalization + command: python main.py + network_mode: "host" + restart: always + + web-docker: + build: + context: . + dockerfile: Web-Dockerfile + command: nginx -c /etc/nginx/nginx.conf -g "daemon off;" + healthcheck: + test: [ "CMD","nginx","-t" ] + network_mode: "host" + restart: always + +# web: +# build: ./web +# command: nginx -c /etc/nginx/nginx.conf -g "daemon off;" +# healthcheck: +# test: [ "CMD","nginx","-t" ] +# network_mode: "host" +# restart: always + # ports: + # - "10001:80" + diff --git a/myems-aggregation/Dockerfile b/myems-aggregation/Dockerfile new file mode 100644 index 00000000..c5a0131c --- /dev/null +++ b/myems-aggregation/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.7 +WORKDIR /code + +COPY . /code +RUN pip install -r requirements.txt diff --git a/myems-aggregation/requirements.txt b/myems-aggregation/requirements.txt new file mode 100644 index 00000000..a6dc3627 --- /dev/null +++ b/myems-aggregation/requirements.txt @@ -0,0 +1 @@ +mysql-connector \ No newline at end of file diff --git a/myems-api/Dockerfile b/myems-api/Dockerfile new file mode 100644 index 00000000..c5a0131c --- /dev/null +++ b/myems-api/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.7 +WORKDIR /code + +COPY . /code +RUN pip install -r requirements.txt diff --git a/myems-api/docker-compose.yml b/myems-api/docker-compose.yml new file mode 100644 index 00000000..3debf9c3 --- /dev/null +++ b/myems-api/docker-compose.yml @@ -0,0 +1,9 @@ +version: '3' +services: + web: + build: . + ports: + - "8000:8000" + volumes: + - .:/code + diff --git a/myems-api/requirements.txt b/myems-api/requirements.txt new file mode 100644 index 00000000..395a9ea9 --- /dev/null +++ b/myems-api/requirements.txt @@ -0,0 +1,8 @@ +anytree +simplejson +mysql.connector +falcon +falcon_cors +falcon-multipart +gunicorn +openpyxl \ No newline at end of file diff --git a/myems-cleaning/Dockerfile b/myems-cleaning/Dockerfile new file mode 100644 index 00000000..c5a0131c --- /dev/null +++ b/myems-cleaning/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.7 +WORKDIR /code + +COPY . /code +RUN pip install -r requirements.txt diff --git a/myems-cleaning/requirements.txt b/myems-cleaning/requirements.txt new file mode 100644 index 00000000..51fbac7f --- /dev/null +++ b/myems-cleaning/requirements.txt @@ -0,0 +1,2 @@ +mysql-connector +schedule \ No newline at end of file diff --git a/myems-modbus-tcp/Dockerfile b/myems-modbus-tcp/Dockerfile new file mode 100644 index 00000000..c5a0131c --- /dev/null +++ b/myems-modbus-tcp/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.7 +WORKDIR /code + +COPY . /code +RUN pip install -r requirements.txt diff --git a/myems-modbus-tcp/requirements.txt b/myems-modbus-tcp/requirements.txt new file mode 100644 index 00000000..a867d987 --- /dev/null +++ b/myems-modbus-tcp/requirements.txt @@ -0,0 +1,3 @@ +mysql-connector +modbus_tk +schedule diff --git a/myems-normalization/Dockerfile b/myems-normalization/Dockerfile new file mode 100644 index 00000000..c5a0131c --- /dev/null +++ b/myems-normalization/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.7 +WORKDIR /code + +COPY . /code +RUN pip install -r requirements.txt diff --git a/myems-normalization/requirements.txt b/myems-normalization/requirements.txt new file mode 100644 index 00000000..67ece48e --- /dev/null +++ b/myems-normalization/requirements.txt @@ -0,0 +1,3 @@ +mysql-connector +openpyxl +sympy \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..d54915f7 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,74 @@ +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + server { + listen 80; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/nginx/web; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + } + + server { + listen 8001; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/nginx/admin; + index index.html index.htm; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + } + + + + +} diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 00000000..df19e649 --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,5 @@ +FROM nginx +WORKDIR /code + +COPY ./build/ /usr/share/nginx/html +#CMD ['nginx', '-c /etc/nginx/nginx.conf', '-g "daemon off;"'] \ No newline at end of file