diff --git a/myems-admin/Dockerfile b/myems-admin/Dockerfile index 89a1bdf1..34cd215b 100644 --- a/myems-admin/Dockerfile +++ b/myems-admin/Dockerfile @@ -1,5 +1,7 @@ FROM nginx:latest +RUN apt update && apt install -y nano + # remove the default config RUN rm /etc/nginx/conf.d/default.conf && \ rm /etc/nginx/nginx.conf diff --git a/myems-admin/README.md b/myems-admin/README.md index 2a14ec7e..93b70e8f 100644 --- a/myems-admin/README.md +++ b/myems-admin/README.md @@ -3,6 +3,7 @@ ## Introduction 系统管理用户界面,用于MyEMS系统配置 + Admin UI for MyEMS system settings ## Prerequisites @@ -16,9 +17,22 @@ nginx-1.18.0 or later In this section, you will install myems-admin on Docker. -* replace ~~127.0.0.1:8000~~ in nginx.conf with actual **HOST** ip and port of myems-api +* Copy source code to root directory + +On Windows: +```bash +cp -r myems/myems-admin c:\ +cd c:\myems-admin +``` + +On Linux: +```bash +cp -r myems/myems-admin / +cd /myems-admin +``` + +* Manually replace ~~127.0.0.1:8000~~ in nginx.conf with actual **HOST** ip and port of myems-api ```bash -cd myems/myems-admin nano nginx.conf ``` @@ -28,17 +42,7 @@ nano nginx.conf * Build a Docker image -On Windows: ```bash -cp -r myems/myems-admin c:\myems-admin -cd c:\myems-admin -docker build -t myems/myems-admin . -``` - -On Linux: -```bash -cp -r myems/myems-admin /myems-admin -cd /myems-admin docker build -t myems/myems-admin . ``` @@ -49,6 +53,7 @@ If run on Windows host, bind-mount a share upload file folder at c:\myems-upload ```bash docker run -d -p 8001:8001 -v c:\myems-upload:/var/www/myems-admin/upload -v c:\myems-admin/nginx.conf:/etc/nginx/nginx.conf:ro --restart always --name myems-admin myems/myems-admin ``` + If run on Linux host, bind-mount a share upload file folder at /myems-upload to the container and also bind-mount nginx.conf ```bash docker run -d -p 8001:8001 -v /myems-upload:/var/www/myems-admin/upload -v /myems-admin/nginx.conf:/etc/nginx/nginx.conf:ro --restart always --name myems-admin myems/myems-admin @@ -72,6 +77,7 @@ If you want to immigrate the image to another computer, ```bash docker save --output myems-admin.tar myems/myems-admin ``` + * Copy the tarball file to another computer, and then load image from tarball file ```bash docker load --input .\myems-admin.tar diff --git a/myems-aggregation/Dockerfile b/myems-aggregation/Dockerfile index 69944ef2..534ceaea 100644 --- a/myems-aggregation/Dockerfile +++ b/myems-aggregation/Dockerfile @@ -1,6 +1,8 @@ FROM python:slim -WORKDIR /code +RUN apt update && apt install -y nano + +WORKDIR /code COPY . /code RUN pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com CMD ["python", "main.py"] \ No newline at end of file diff --git a/myems-aggregation/README.md b/myems-aggregation/README.md index b440a219..564e4c6d 100644 --- a/myems-aggregation/README.md +++ b/myems-aggregation/README.md @@ -6,7 +6,7 @@ Data Aggregation Service ## Introduction -This service is a component of MyEMS. It aggregates normalized data up to multiple dimensions. +This service is a component of MyEMS to aggregate normalized data up to multiple dimensions. ## Prerequisites @@ -45,22 +45,27 @@ cp -r myems/myems-aggregation / cd /myems/myems-aggregation ``` -* Duplicate example.env file as .env file and modify the .env file -Replace ~~127.0.0.1~~ with real **HOST** IP address. +* Create .env file based on example.env file + +Manually replace ~~127.0.0.1~~ with real **HOST** IP address. + ```bash cp example.env .env ``` * Build a Docker image +* ```bash docker build -t myems/myems-aggregation . ``` + * Run a Docker container On Windows host, bind-mount the .env to the container: ```bash docker run -d -v c:\myems-aggregation\.env:/code/.env:ro --restart always --name myems-aggregation myems/myems-aggregation ``` + On Linux host, bind-mount the .env to the container: ```bash docker run -d -v /myems-aggregation/.env:/code/.env:ro --restart always --name myems-aggregation myems/myems-aggregation diff --git a/myems-api/Dockerfile b/myems-api/Dockerfile index 9392e18e..3c5e716e 100644 --- a/myems-api/Dockerfile +++ b/myems-api/Dockerfile @@ -1,9 +1,11 @@ FROM python:slim -WORKDIR /code + +# RUN apt update && apt install -y nano # todo: share upload folder with admin container on Docker RUN mkdir -p /var/www/myems-admin/upload +WORKDIR /code COPY . /code RUN pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com EXPOSE 8000 diff --git a/myems-api/README.md b/myems-api/README.md index 83e95687..2b279935 100644 --- a/myems-api/README.md +++ b/myems-api/README.md @@ -69,25 +69,31 @@ waitress-serve --listen=127.0.0.1:8000 app:api In this section, you will install myems-api on Docker. -* Duplicate example.env file as .env file and modify the .env file -Replace ~~127.0.0.1~~ with real **HOST** IP address. -```bash -cp example.env .env -``` - -* Build a Docker image +* Copy source code to root directory On Windows: ```bash cp -r myems/myems-api c:\ cd c:\myems-api -docker build -t myems/myems-api . ``` On Linux: ```bash cp -r myems/myems-api / cd /myems-api +``` + +* Create .env file based on example.env file + +Manually replace ~~127.0.0.1~~ with real **HOST** IP address. + +```bash +cp example.env .env +``` + +* Build a Docker image + +```bash docker build -t myems/myems-api . ``` diff --git a/myems-cleaning/Dockerfile b/myems-cleaning/Dockerfile index 69944ef2..534ceaea 100644 --- a/myems-cleaning/Dockerfile +++ b/myems-cleaning/Dockerfile @@ -1,6 +1,8 @@ FROM python:slim -WORKDIR /code +RUN apt update && apt install -y nano + +WORKDIR /code COPY . /code RUN pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com CMD ["python", "main.py"] \ No newline at end of file diff --git a/myems-cleaning/README.md b/myems-cleaning/README.md index 607713ed..d1e7842d 100644 --- a/myems-cleaning/README.md +++ b/myems-cleaning/README.md @@ -1,11 +1,12 @@ # myems-cleaning + MyEMS Cleaning Service MyEMS 数据清洗服务 ## Introduction -This service is a component of MyEMS. It cleans the historical data. +This service is a component of MyEMS to clean the historical data. ## Prerequisites @@ -44,8 +45,10 @@ cp -r myems/myems-cleaning / cd /myems-cleaning ``` -* Duplicate example.env file as .env file and modify the .env file -Replace ~~127.0.0.1~~ with real **HOST** IP address. +* Create .env file based on example.env file + +Manually replace ~~127.0.0.1~~ with real **HOST** IP address. + ```bash cp example.env .env ``` @@ -54,16 +57,19 @@ cp example.env .env ```bash docker build -t myems/myems-cleaning . ``` + * Run a Docker container On Windows host, bind-mount the .env to the container: ```bash docker run -d -v c:\myems-cleaning\.env:/code/.env:ro --restart always --name myems-cleaning myems/myems-cleaning ``` + On Linux host, bind-mount the .env to the container: ```bash docker run -d -v /myems-cleaning/.env:/code/.env:ro --restart always --name myems-cleaning myems/myems-cleaning ``` + * -d Run container in background and print container ID * -v If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, diff --git a/myems-modbus-tcp/Dockerfile b/myems-modbus-tcp/Dockerfile index 69944ef2..534ceaea 100644 --- a/myems-modbus-tcp/Dockerfile +++ b/myems-modbus-tcp/Dockerfile @@ -1,6 +1,8 @@ FROM python:slim -WORKDIR /code +RUN apt update && apt install -y nano + +WORKDIR /code COPY . /code RUN pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com CMD ["python", "main.py"] \ No newline at end of file diff --git a/myems-modbus-tcp/README.md b/myems-modbus-tcp/README.md index aa1b0e3d..76933f7f 100644 --- a/myems-modbus-tcp/README.md +++ b/myems-modbus-tcp/README.md @@ -2,7 +2,7 @@ ### Introduction -This service is a component of MyEMS Community Edition to acquire data from Modbus TCP devices. +This service is a component of MyEMS to acquire data from Modbus TCP devices. ### Prerequisites @@ -45,8 +45,10 @@ cp -r myems/myems-modbus-tcp / cd /myems-modbus-tcp ``` -* Duplicate example.env file as .env file and modify the .env file -Replace ~~127.0.0.1~~ with real **HOST** IP address. +* Create .env file based on example.env file + +Manually replace ~~127.0.0.1~~ with real **HOST** IP address. + ```bash cp example.env .env ``` @@ -55,16 +57,19 @@ cp example.env .env ```bash docker build -t myems/myems-modbus-tcp . ``` + * Run a Docker container On Windows host, bind-mount the .env to the container: ```bash docker run -d -v c:\myems-modbus-tcp\.env:/code/.env:ro --restart always --name myems-modbus-tcp myems/myems-modbus-tcp ``` + On Linux host, bind-mount the .env to the container: ```bash docker run -d -v /myems-modbus-tcp/.env:/code/.env:ro --restart always --name myems-modbus-tcp myems/myems-modbus-tcp ``` + * -d Run container in background and print container ID * -v If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, diff --git a/myems-normalization/Dockerfile b/myems-normalization/Dockerfile index 69944ef2..534ceaea 100644 --- a/myems-normalization/Dockerfile +++ b/myems-normalization/Dockerfile @@ -1,6 +1,8 @@ FROM python:slim -WORKDIR /code +RUN apt update && apt install -y nano + +WORKDIR /code COPY . /code RUN pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com CMD ["python", "main.py"] \ No newline at end of file diff --git a/myems-normalization/README.md b/myems-normalization/README.md index fb170944..85926d12 100644 --- a/myems-normalization/README.md +++ b/myems-normalization/README.md @@ -6,7 +6,7 @@ MyEMS Normalization Service ## Introduction -This service is a component of MyEMS. It normalizes energy data in historical database. +This service is a component of MyEMS to normalize energy data in historical database. ![MyEMS Meter Normalization](../docs/images/meter-normalization.png) @@ -51,10 +51,10 @@ cp -r myems/myems-normalization / cd /myems-normalization ``` -* Create .env file +* Create .env file based on example.env file + +Manually replace ~~127.0.0.1~~ with real **HOST** IP address. -Duplicate example.env file as .env file and modify the .env file -Replace ~~127.0.0.1~~ with real **HOST** IP address. ```bash cp example.env .env ``` @@ -63,6 +63,7 @@ cp example.env .env ```bash docker build -t myems/myems-normalization . ``` + * Run a Docker container On Windows host, bind-mount the .env to the container: diff --git a/myems-web/Dockerfile b/myems-web/Dockerfile index 87baa41f..dba42800 100644 --- a/myems-web/Dockerfile +++ b/myems-web/Dockerfile @@ -1,4 +1,4 @@ -FROM node:latest as build-stage +FROM node:latest as build-stage WORKDIR /opt COPY . . RUN npm install --registry https://registry.npm.taobao.org @@ -7,14 +7,14 @@ RUN npm run build FROM nginx:latest as production-stage +RUN apt update && apt install -y nano + # remove the default config RUN rm /etc/nginx/conf.d/default.conf && rm /etc/nginx/nginx.conf # create new root folder RUN mkdir -p /var/www/myems-web -# Note: You should run 'npm run build' in the web direction to generate the production build. - COPY nginx.conf /etc/nginx/ COPY --from=build-stage /opt/build/ /var/www/myems-web EXPOSE 80 diff --git a/myems-web/README.md b/myems-web/README.md index 58118d73..e9176d6e 100644 --- a/myems-web/README.md +++ b/myems-web/README.md @@ -3,6 +3,7 @@ ## Introduction Web用户界面,用于MyEMS能源数据可视化 + Web UI for MyEMS energy data visualization ## Prerequisites @@ -72,21 +73,26 @@ cd myems/myems-web nano nginx.conf ``` -* Build a Docker image -**NOTE**: You can safely ignore the command 'npm run build' in this section, because it is built into the Dockerfile +* Copy source code to root directory On Windows: ```bash -cp -r myems/myems-web c:\myems-web +cp -r myems/myems-web c:\ cd c:\myems-web -docker build -t myems/myems-web . ``` On Linux: ```bash -cp -r myems/myems-web /myems-web +cp -r myems/myems-web / cd /myems-web +``` + +**NOTE**: You can safely ignore the command 'npm run build' in this section, because it is built into the Dockerfile + +* Build a Docker image + +```bash docker build -t myems/myems-web . ``` @@ -119,6 +125,7 @@ If you want to immigrate the image to another computer, ```bash docker save --output myems-web.tar myems/myems-web ``` + * Copy the tarball file to another computer, and then load image from tarball file ```bash docker load --input .\myems-web.tar