added Dockerfiles

Merge branch 'PR56' into develop
pull/57/MERGE
13621160019@163.com 2021-07-30 19:06:06 +08:00
commit 7fbb562a62
16 changed files with 245 additions and 0 deletions

View File

@ -66,6 +66,19 @@ MyEMS项目由下列组件构成:
[安装 web UI](./web/README.md)
### Docker Docker-compose 安装
```
git clone https://gitee.com/myems/myems.git
# for generate the static direction: 'build'
cd myems/web
npm run build
cd myems
docker-compose up -d
```
## 功能版本对比
| 功能 |社区版 |企业版 | 说明 |
| :--- | :----: | :----: | :----: |

11
admin/Dockerfile vendored Normal file
View File

@ -0,0 +1,11 @@
FROM nginx
# remove the config
RUN rm /etc/nginx/conf.d/default.conf && \
rm /etc/nginx/nginx.conf && \
mkdir -p /usr/share/nginx/admin
# copy the config and web codes
COPY nginx.conf /etc/nginx/
COPY . /usr/share/nginx/admin
CMD ['nginx', '-c /etc/nginx/nginx.conf', '-g "daemon off;"']

57
admin/nginx.conf vendored Normal file
View File

@ -0,0 +1,57 @@
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 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;
}
location /api {
proxy_pass http://127.0.0.1:8000/;
proxy_connect_timeout 75;
proxy_read_timeout 600;
send_timeout 600;
}
}
}

47
docker-compose.yml Normal file
View File

@ -0,0 +1,47 @@
version: '3'
services:
api:
build: ./myems-api
command: gunicorn app:api -b 0.0.0.0:8000
network_mode: "host"
restart: always
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
admin:
build: ./admin
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

View File

@ -0,0 +1,6 @@
FROM python:3.7
WORKDIR /code
COPY . /code
RUN pip install -r requirements.txt
CMD ['python', 'main.py']

View File

@ -0,0 +1 @@
mysql-connector

6
myems-api/Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM python:3.7
WORKDIR /code
COPY . /code
RUN pip install -r requirements.txt
CMD ['gunicorn', 'app:api', '-b 0.0.0.0:8000']

View File

@ -0,0 +1,9 @@
anytree
simplejson
mysql.connector
falcon
falcon_cors
falcon-multipart
gunicorn
openpyxl
pillow

View File

@ -0,0 +1,6 @@
FROM python:3.7
WORKDIR /code
COPY . /code
RUN pip install -r requirements.txt
CMD ['python', 'main.py']

View File

@ -0,0 +1,2 @@
mysql-connector
schedule

View File

@ -0,0 +1,6 @@
FROM python:3.7
WORKDIR /code
COPY . /code
RUN pip install -r requirements.txt
CMD ['python', 'main.py']

View File

@ -0,0 +1,3 @@
mysql-connector
modbus_tk
schedule

View File

@ -0,0 +1,6 @@
FROM python:3.7
WORKDIR /code
COPY . /code
RUN pip install -r requirements.txt
CMD ['python', 'main.py']

View File

@ -0,0 +1,3 @@
mysql-connector
openpyxl
sympy

13
web/Dockerfile vendored Normal file
View File

@ -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
# copy the config and web codes
# Attention:
# You should run 'npm run build' in the web direction to generate the build direction because this's a react projection.
COPY nginx.conf /etc/nginx/
COPY . /usr/share/nginx/web
CMD ['nginx', '-c /etc/nginx/nginx.conf', '-g "daemon off;"']

56
web/nginx.conf vendored Normal file
View File

@ -0,0 +1,56 @@
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;
}
location /api {
proxy_pass http://127.0.0.1:8000/;
proxy_connect_timeout 75;
proxy_read_timeout 600;
send_timeout 600;
}
}
}