Podman على لينكس
في هذا الدليل، ستقوم بنشر MyEMS باستخدام Podman على نظام لينكس.
المتطلبات المسبقة
- تم تثبيت podman و npm على الجهاز المضيف.
- تم تثبيت خادم MySQL.
- يمكن الاتصال بقاعدة بيانات MySQL من الجهاز المضيف الذي يعمل عليه Podman Engine.
-
يُوصى باستخدام صلاحيات الجذر لتنفيذ أوامر podman.
-
بعد تثبيت podman، استخدم الأمر
systemctl status podman-restart.serviceللتحقق مما إذا كانت الحاويات معدة للتشغيل التلقائي. إذا ظهرت رسالةUnit not foundفهذا يعني أن الحاوية لا يمكن تشغيلها تلقائيًا.
الخطوة 1: قاعدة البيانات
راجع قاعدة البيانات
الخطوة 2: myems-api
في هذا القسم، ستقوم بتثبيت myems-api على Podman.
- انسخ الشيفرة المصدرية إلى الد ليل الجذري
cp -r myems/myems-api /
cd /myems-api
- أنشئ ملف .env بناءً على example.env
استبدل يدويًا 127.0.0.1 بعنوان IP الحقيقي للجهاز HOST.
cp example.env .env
- بناء الصورة من الشيفرة المصدرية
podman build -t myems/myems-api .
لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).
podman buildx build --platform=linux/amd64 -t myems/myems-api .
- تشغيل حاوية Podman
On host, create a share upload file folder:
mkdir /myems-upload
Create a container, bind-mount the share folder to the container, and also bind-mount the .env to the container:
podman run -d -p 8000:8000 -v /myems-upload:/var/www/myems-admin/upload -v /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 Podman 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
podman save --output myems-api.tar myems/myems-api
- انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
podman load --input .\myems-api.tar
الخطوة 3: myems-admin
في هذا القسم، ستقوم بتثبيت myems-admin على Podman.
- انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-admin /
cd /myems-admin
استبدل يدويًا 127.0.0.1:8000 في nginx.conf بعنوان IP والمنفذ الحقيقيين لخدمة myems-api
nano nginx.conf
proxy_pass http://127.0.0.1:8000/;
- بناء الصورة من الشيفرة المصدرية
podman build -t myems/myems-admin .
لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).
podman buildx build --platform=linux/amd64 -t myems/myems-admin .
- تشغيل حاوية Podman
On host, create a share upload file folder:
mkdir /myems-upload
Create a container, bind-mount the share upload file folder to the container and also bind-mount nginx.conf
podman run -d -p 8001:8001 -v /myems-upload:/var/www/myems-admin/upload -v /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 Podman 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
podman save --output myems-admin.tar myems/myems-admin
- انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
podman load --input .\myems-admin.tar
الخطوة 4: myems-modbus-tcp
في هذا القسم، ستقوم بتثبيت myems-modbus-tcp على Podman.
- انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-modbus-tcp /
cd /myems-modbus-tcp
- أنشئ ملف .env بناءً على example.env
استبدل يدويًا 127.0.0.1 بعنوان IP الحقيقي للجهاز HOST.
cp example.env .env
- بناء الصورة من الشيفرة المصدرية
podman build -t myems/myems-modbus-tcp .
لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).
podman buildx build --platform=linux/amd64 -t myems/myems-modbus-tcp .
- تشغيل حاوية Podman (كمستخدم جذر)
podman run -d -v /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 Podman 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، أعد تشغيل الحاوية لتطبيق التغييرات.
- نقل حاوية Podman
لنقل الحاوية إلى جهاز آخر:
- صدّر الصورة إلى ملف tarball
podman save --output myems-modbus-tcp.tar myems/myems-modbus-tcp
- انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
podman load --input .\myems-modbus-tcp.tar
الخطوة 5: myems-cleaning
في هذا القسم، ستقوم بتثبيت myems-cleaning على Podman.
- انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-cleaning /
cd /myems-cleaning
- أنشئ ملف .env بناءً على example.env
استبدل يدويًا 127.0.0.1 بعنوان IP الحقيقي للجهاز HOST.
cp example.env .env
- بناء الصورة من الشيفرة المصدرية
podman build -t myems/myems-cleaning .
لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).
podman buildx build --platform=linux/amd64 -t myems/myems-cleaning .
- تشغيل حاوية Podman (كمستخدم جذر)
podman run -d -v /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 Podman 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، أعد تشغيل الحاوية لتطبيق التغييرات.
- نقل حاوية Podman
لنقل الحاوية إلى جهاز آخر:
- صدّر الصورة إلى ملف tarball
podman save --output myems-cleaning.tar myems/myems-cleaning
- انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
podman load --input .\myems-cleaning.tar
الخطوة 6: myems-normalization
في هذا القسم، ستقوم بتثبيت myems-normalization على Podman.
- انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-normalization /
cd /myems-normalization
- أنشئ ملف .env بناءً على example.env
استبدل يدويًا 127.0.0.1 بعنوان IP الحقيقي للجهاز HOST.
cp example.env .env
- بناء الصورة من الشيفرة المصدرية
podman build -t myems/myems-normalization .
لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).
podman buildx build --platform=linux/amd64 -t myems/myems-normalization .
- تشغيل حاوية Podman (كمستخدم جذر)
podman run -d -v /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 Podman 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، أعد تشغيل الحاوية لتطبيق التغييرات.
- نقل حاوية Podman
لنقل الحاوية إلى جهاز آخر:
- صدّر الصورة إلى ملف tarball
podman save --output myems-normalization.tar myems/myems-normalization
- انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
podman load --input .\myems-normalization.tar
الخطوة 7: myems-aggregation
في هذا القسم، ستقوم بتثبيت myems-aggregation على Podman.
- انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-aggregation /
cd /myems-aggregation
- أنشئ ملف .env بناءً على example.env
cp example.env .env
استبدل يدويًا 127.0.0.1 بعنوان IP الحقيقي للجهاز HOST.
- بناء الصورة من الشيفرة المصدرية
podman build -t myems/myems-aggregation .
لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).
podman buildx build --platform=linux/amd64 -t myems/myems-aggregation .
- تشغيل حاوية Podman (كمستخدم جذر)
podman run -d -v /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 Podman 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، أعد تشغيل الحاوية لتطبيق التغييرات.
-
نقل حاوية Podman
-
صدّر الصورة إلى ملف tarball
podman save --output myems-aggregation.tar myems/myems-aggregation
- انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
podman load --input .\myems-aggregation.tar
الخطوة 8: myems-web
في هذا القسم، ستقوم بتثبيت myems-web على Podman.
- تعديل ملف config.js:
احصل على mapboxToken من https://mapbox.com ثم عيّن showOnlineMap إلى true. إذا كنت تريد إيقاف ميزة الخريطة عبر الإنترنت، عيّن showOnlineMap إلى false
cd myems/myems-web
nano src/config.js
استبدل 127.0.0.1:8000 في nginx.conf بعنوان IP والمنفذ الحقيقيين لخدمة myems-api
cd myems/myems-web
nano nginx.conf
- انسخ الشيفرة المصدرية إلى الدليل الجذري
cp -r myems/myems-web /
cd /myems-web
يمكنك تجاهل أمر 'npm run build' في هذا القسم بأمان، لأنه مدمج في Podmanfile
- بناء الصورة من الشيفرة المصدرية
podman build -t myems/myems-web .
لبناء الصورة لأنظمة متعددة وليس فقط لنظام التشغيل والمعمارية التي يعمل عليها المستخدم الحالي، يمكنك استخدام buildx وتعيين الخيار --platform لتحديد النظام المستهدف (مثلاً: linux/amd64 أو linux/arm64 أو darwin/amd64).
podman buildx build --platform=linux/amd64 -t myems/myems-web .
- تشغيل حاوية Podman
On host, bind-mount nginx.conf
podman run -d -p 80:80 -v /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 Podman 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
podman save --output myems-web.tar myems/myems-web
- انسخ ملف tarball إلى جهاز آخر ثم قم بتحميل الصورة منه
podman load --input .\myems-web.tar
ما بعد التثبيت
تهانينا! يمكنك الآن تسجيل الدخول إلى واجهة إدارة MyEMS وواجهة الويب.