انتقل إلى المحتوى الرئيسي

Docker على ويندوز

في هذا الدليل، ستقوم بنشر MyEMS باستخدام Docker على نظام ويندوز.

المتطلبات المسبقة

  • تم تثبيت docker و npm على الجهاز المضيف.
  • تم تثبيت خادم MySQL.
  • يمكن الاتصال بقاعدة بيانات MySQL من الجهاز المضيف الذي يعمل عليه Docker Engine.
  • متطلبات الأجهزة: ذاكرة عشوائية لا تقل عن 4 جيجابايت، ومساحة تخزين 20 جيجابايت (لقاعدة البيانات وحاوية Docker).

استنساخ الشيفرة المصدرية:

cd ~
git clone https://github.com/myems/myems

الخطوة 1: قاعدة البيانات

راجع قاعدة البيانات

الخطوة 2: myems-api

في هذا القسم، ستقوم بتثبيت myems-api على Docker.

  • انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-api c:\
cd c:\myems-api
  • أنشئ ملف .env بناءً على example.env
احذر

استبدل يدويًا 127.0.0.1 بعنوان IP الحقيقي للجهاز HOST.

cp example.env .env
  • بناء الصورة من الشيفرة المصدرية
docker build -t myems/myems-api .

لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).

docker buildx build --platform=linux/amd64 -t myems/myems-api .
  • تشغيل حاوية Docker

On host, create a folder at c:\myems-upload, and bind-mount it to the container, and also bind-mount the .env to the container:

docker run -d -p 8000:8000 -v c:\myems-upload:/var/www/myems-admin/upload -v c:\myems-api\.env:/app/.env:ro --log-opt max-size=1m --log-opt max-file=2 --restart always --name myems-api myems/myems-api
  • -d Run container in background and print container ID

  • -p Publish a container's port(s) to the host, 8000:8000 (Host:Container) binds port 8000 (right) of the container to TCP port 8000 (left) of the host machine.

  • -v If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v creates the endpoint for you. It is always created as a directory. The ro option, if present, causes the bind mount to be mounted into the container as read-only. For v4.7.0 or earlier versions, use '/code/.env' instead of '/app/.env'.

  • --log-opt max-size=2m The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g).

  • --log-opt max-file=2 The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer.

  • --restart Restart policy to apply when a container exits

  • --name Assign a name to the container

المسار المطلق قبل النقطتين هو للمضيف وقد يختلف حسب نظامك. المسار بعد النقطتين هو للمسار داخل الحاوية ولا يمكن تغييره. بتمرير ملف .env كمعامل bind-mount يمكنك تغيير الإعدادات لاحقًا. إذا قمت بتعديل ملف .env، أعد تشغيل الحاوية لتطبيق التغييرات.

إذا كنت تريد نقل الصورة إلى جهاز آخر:

  • صدّر الصورة إلى ملف tarball
docker save --output myems-api.tar myems/myems-api
  • انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
docker load --input .\myems-api.tar

الخطوة 3: myems-admin

في هذا القسم، ستقوم بتثبيت myems-admin على Docker.

  • انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-admin c:\
cd c:\myems-admin
احذر

استبدل يدويًا 127.0.0.1:8000 في nginx.conf بعنوان IP والمنفذ الحقيقيين لخدمة myems-api

notepad nginx.conf
      proxy_pass http://127.0.0.1:8000/;
  • بناء الصورة من الشيفرة المصدرية
docker build -t myems/myems-admin .

لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).

docker buildx build --platform=linux/amd64 -t myems/myems-admin .
  • تشغيل حاوية Docker

On host, create a folder at c:\myems-upload, and bind-mount it to the container, and also bind-mount the nginx.conf to the container: -v parameter for upload folder must be same with that in myems-api

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 --log-opt max-size=1m --log-opt max-file=2 --restart always --name myems-admin myems/myems-admin
  • -d Run container in background and print container ID

  • -p Publish a container's port(s) to the host, 8001:8001 (Host:Container) binds port 8001 (right) of the container to TCP port 8001 (left) of the host machine.

  • -v If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v creates the endpoint for you. It is always created as a directory. The ro option, if present, causes the bind mount to be mounted into the container as read-only. For v4.7.0 or earlier versions, use '/code/.env' instead of '/app/.env'.

  • --log-opt max-size=2m The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g).

  • --log-opt max-file=2 The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer.

  • --restart Restart policy to apply when a container exits

  • --name Assign a name to the container

إذا كنت تريد نقل الصورة إلى جهاز آخر:

  • صدّر الصورة إلى ملف tarball
docker save --output myems-admin.tar myems/myems-admin
  • انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
docker load --input .\myems-admin.tar

الخطوة 4: myems-modbus-tcp

في هذا القسم، ستقوم بتثبيت myems-modbus-tcp على Docker.

  • انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-modbus-tcp c:\
cd c:\myems-modbus-tcp
  • أنشئ ملف .env بناءً على example.env
احذر

استبدل يدويًا 127.0.0.1 بعنوان IP الحقيقي للجهاز HOST.

cp example.env .env
  • بناء الصورة من الشيفرة المصدرية
docker build -t myems/myems-modbus-tcp .

لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).

docker buildx build --platform=linux/amd64 -t myems/myems-modbus-tcp .
  • تشغيل حاوية Docker (كمدير النظام)
docker run -d -v c:\myems-modbus-tcp\.env:/app/.env:ro --log-opt max-size=1m --log-opt max-file=2 --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, -v creates the endpoint for you. It is always created as a directory. The ro option, if present, causes the bind mount to be mounted into the container as read-only. For v4.7.0 or earlier versions, use '/code/.env' instead of '/app/.env'.

  • --log-opt max-size=2m The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g).

  • --log-opt max-file=2 The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer.

  • --restart Restart policy to apply when a container exits

  • --name Assign a name to the container

المسار المطلق قبل النقطتين هو للمضيف وقد يختلف حسب نظامك. المسار بعد النقطتين هو للمسار داخل الحاوية ولا يمكن تغييره. بتمرير ملف .env كمعامل bind-mount يمكنك تغيير الإعدادات لاحقًا. إذا قمت بتعديل ملف .env، أعد تشغيل الحاوية لتطبيق التغييرات.

  • نقل حاوية Docker

لنقل الحاوية إلى جهاز آخر:

  • صدّر الصورة إلى ملف tarball
docker save --output myems-modbus-tcp.tar myems/myems-modbus-tcp
  • انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
docker load --input .\myems-modbus-tcp.tar

الخطوة 5: myems-cleaning

في هذا القسم، ستقوم بتثبيت myems-cleaning على Docker.

  • انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-cleaning c:\
cd c:\myems-cleaning
  • أنشئ ملف .env بناءً على example.env
احذر

استبدل يدويًا 127.0.0.1 بعنوان IP الحقيقي للجهاز HOST.

cp example.env .env
  • بناء الصورة من الشيفرة المصدرية
docker build -t myems/myems-cleaning .

لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).

docker buildx build --platform=linux/amd64 -t myems/myems-cleaning .
  • تشغيل حاوية Docker (كمدير النظام)
docker run -d -v c:\myems-cleaning\.env:/app/.env:ro --log-opt max-size=1m --log-opt max-file=2 --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, -v creates the endpoint for you. It is always created as a directory. The ro option, if present, causes the bind mount to be mounted into the container as read-only. For v4.7.0 or earlier versions, use '/code/.env' instead of '/app/.env'.

  • --log-opt max-size=2m The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g).

  • --log-opt max-file=2 The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer.

  • --restart Restart policy to apply when a container exits

  • --name Assign a name to the container

المسار المطلق قبل النقطتين هو للمضيف وقد يختلف حسب نظامك. المسار بعد النقطتين هو للمسار داخل الحاوية ولا يمكن تغييره. بتمرير ملف .env كمعامل bind-mount يمكنك تغيير الإعدادات لاحقًا. إذا قمت بتعديل ملف .env، أعد تشغيل الحاوية لتطبيق التغييرات.

  • نقل حاوية Docker

لنقل الحاوية إلى جهاز آخر:

  • صدّر الصورة إلى ملف tarball
docker save --output myems-cleaning.tar myems/myems-cleaning
  • انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
docker load --input .\myems-cleaning.tar

الخطوة 6: myems-normalization

في هذا القسم، ستقوم بتثبيت myems-normalization على Docker.

  • انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-normalization c:\
cd c:\myems-normalization
  • أنشئ ملف .env بناءً على example.env
احذر

استبدل يدويًا 127.0.0.1 بعنوان IP الحقيقي للجهاز HOST.

cp example.env .env
  • بناء الصورة من الشيفرة المصدرية
docker build -t myems/myems-normalization .

لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).

docker buildx build --platform=linux/amd64 -t myems/myems-normalization .
  • تشغيل حاوية Docker (كمدير النظام)
docker run -d -v c:\myems-normalization\.env:/app/.env:ro --log-opt max-size=1m --log-opt max-file=2 --restart always --name myems-normalization myems/myems-normalization
  • -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, -v creates the endpoint for you. It is always created as a directory. The ro option, if present, causes the bind mount to be mounted into the container as read-only. For v4.7.0 or earlier versions, use '/code/.env' instead of '/app/.env'.

  • --log-opt max-size=2m The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g).

  • --log-opt max-file=2 The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer.

  • --restart Restart policy to apply when a container exits

  • --name Assign a name to the container

المسار المطلق قبل النقطتين هو للمضيف وقد يختلف حسب نظامك. المسار بعد النقطتين هو للمسار داخل الحاوية ولا يمكن تغييره. بتمرير ملف .env كمعامل bind-mount يمكنك تغيير الإعدادات لاحقًا. إذا قمت بتعديل ملف .env، أعد تشغيل الحاوية لتطبيق التغييرات.

  • نقل حاوية Docker

لنقل الحاوية إلى جهاز آخر:

  • صدّر الصورة إلى ملف tarball
docker save --output myems-normalization.tar myems/myems-normalization
  • انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
docker load --input .\myems-normalization.tar

الخطوة 7: myems-aggregation

في هذا القسم، ستقوم بتثبيت myems-aggregation على Docker.

  • انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-aggregation c:\
cd c:\myems-aggregation
  • أنشئ ملف .env بناءً على example.env
احذر

استبدل يدويًا 127.0.0.1 بعنوان IP الحقيقي للجهاز HOST.

cp example.env .env
  • بناء الصورة من الشيفرة المصدرية
docker build -t myems/myems-aggregation .

لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).

docker buildx build --platform=linux/amd64 -t myems/myems-aggregation .
  • تشغيل حاوية Docker (كمدير النظام)
docker run -d -v c:\myems-aggregation\.env:/app/.env:ro --log-opt max-size=1m --log-opt max-file=2 --restart always --name myems-aggregation myems/myems-aggregation
  • -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, -v creates the endpoint for you. It is always created as a directory. The ro option, if present, causes the bind mount to be mounted into the container as read-only. For v4.7.0 or earlier versions, use '/code/.env' instead of '/app/.env'.

  • --log-opt max-size=2m The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g).

  • --log-opt max-file=2 The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer.

  • --restart Restart policy to apply when a container exits

  • --name Assign a name to the container

المسار المطلق قبل النقطتين هو للمضيف وقد يختلف حسب نظامك. المسار بعد النقطتين هو للمسار داخل الحاوية ولا يمكن تغييره. بتمرير ملف .env كمعامل bind-mount يمكنك تغيير الإعدادات لاحقًا. إذا قمت بتعديل ملف .env، أعد تشغيل الحاوية لتطبيق التغييرات.

  • نقل حاوية Docker

  • صدّر الصورة إلى ملف tarball

docker save --output myems-aggregation.tar myems/myems-aggregation
  • انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
docker load --input .\myems-aggregation.tar

الخطوة 8: myems-web

في هذا القسم، ستقوم بتثبيت myems-web على Docker.

  • تعديل ملف config.js:
ملاحظة

احصل على mapboxToken من https://mapbox.com ثم عيّن showOnlineMap إلى true. إذا كنت تريد إيقاف ميزة الخريطة عبر الإنترنت، عيّن showOnlineMap إلى false

cd myems/myems-web
notepad src/config.js
احذر

استبدل 127.0.0.1:8000 في nginx.conf بعنوان IP والمنفذ الحقيقيين لخدمة myems-api

cd myems/myems-web
notepad nginx.conf
  • انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-web c:\
cd c:\myems-web
معلومات

يمكنك تجاهل أمر 'npm run build' في هذا القسم بأمان، لأنه مدمج في Dockerfile

  • بناء الصورة من الشيفرة المصدرية
docker build -t myems/myems-web .
docker image prune -f

لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).

docker buildx build --platform=linux/amd64 -t myems/myems-web .
docker image prune -f
  • تشغيل حاوية Docker

On host, bind-mount nginx.conf

docker run -d -p 80:80 -v c:\myems-web/nginx.conf:/etc/nginx/nginx.conf:ro --log-opt max-size=1m --log-opt max-file=2 --restart always --name myems-web myems/myems-web
  • -d Run container in background and print container ID

  • -p Publish a container's port(s) to the host, 80:80 (Host:Container) binds port 80 (right) of the container to TCP port 80 (left) of the host machine.

  • -v If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v creates the endpoint for you. It is always created as a directory. The ro option, if present, causes the bind mount to be mounted into the container as read-only. For v4.7.0 or earlier versions, use '/code/.env' instead of '/app/.env'.

  • --log-opt max-size=2m The maximum size of the log before it is rolled. A positive integer plus a modifier representing the unit of measure (k, m, or g).

  • --log-opt max-file=2 The maximum number of log files that can be present. If rolling the logs creates excess files, the oldest file is removed. A positive integer.

  • --restart Restart policy to apply when a container exits

  • --name Assign a name to the container

إذا كنت تريد نقل الصورة إلى جهاز آخر:

  • صدّر الصورة إلى ملف tarball
docker save --output myems-web.tar myems/myems-web
  • انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
docker load --input .\myems-web.tar

ما بعد التثبيت

تهانينا! يمكنك الآن تسجيل الدخول إلى واجهة إدارة MyEMS وواجهة الويب.

المنافذ الافتراضية

واجهة MyEMS Web UI: 80

واجهة MyEMS API: 8000

واجهة MyEMS Admin UI: 8001

على افتراض أن عنوان الخادم هو 192.168.1.8 (استبدله بعنوان الخادم الفعلي) ادخل إلى MyEMS Web UI عبر http://192.168.1.8 (يمكن إهمال 80) ادخل إلى MyEMS Admin UI عبر http://192.168.1.8:8001

كلمات المرور الافتراضية

واجهة MyEMS Admin UI

اسم المستخدم:

administrator

كلمة المرور:

!MyEMS1

واجهة MyEMS Web UI

اسم المستخدم:

administrator@myems.io

كلمة المرور:

!MyEMS1

استكشاف الأخطاء وإصلاحها

كيفية حل مشكلات بطء سحب الصور

بسبب مشاكل في مزود خدمة الإنترنت، قد تواجه بطء في سحب الصور. يمكنك استخدام خدمات تسريع طرف ثالث.