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