Ir al contenido principal

Podman en Linux

En esta guía, desplegará MyEMS con Podman en Linux.

Requisitos previos

  • Podman y npm instalados en el host.
  • Servidor MySQL instalado.
  • La base de datos MySQL debe ser accesible desde el host donde se ejecuta el motor Podman.
Precaución
  • Se recomienda usar privilegios de root para ejecutar los comandos de podman.

  • Después de instalar podman, use el comando systemctl status podman-restart.service para comprobar si los contenedores están configurados para el inicio automático y la política correspondiente. Si aparece Unit not found, significa que el contenedor no puede iniciarse automáticamente.

Step 1 Database

Consulte Base de datos

Step 2 myems-api

En esta sección, instalará myems-api en Podman.

  • Copie el código fuente al directorio raíz
cp -r myems/myems-api /
cd /myems-api
  • Cree el archivo .env basado en el archivo example.env
Precaución

Reemplace manualmente 127.0.0.1 con la dirección IP real del HOST.

cp example.env .env
  • Construya la imagen desde el código fuente
podman build -t myems/myems-api .

Para compilar para múltiples plataformas y no solo para la arquitectura y el sistema operativo en el que se ejecuta el usuario que invoca la compilación. Puede usar buildx y establecer la bandera --platform para especificar la plataforma de destino para la salida de la compilación (por ejemplo, linux/amd64, linux/arm64 o darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-api .
  • Ejecute un contenedor Podman

En el host, cree una carpeta compartida para archivos de subida:

mkdir /myems-upload

Cree un contenedor, monte la carpeta compartida en el contenedor y también monte el archivo .env en el contenedor:

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

The absolute path before colon is for path on host and that may vary on your system. The absolute path after colon is for path on container and that CANNOT be changed. By passing .env as bind-mount parameter, you can change the configuration values later. If you changed .env file, restart the container to make the change effective.

Si desea migrar la imagen a otro equipo,

  • Exporte la imagen a un archivo tarball
podman save --output myems-api.tar myems/myems-api
  • Copie el archivo tarball a otro equipo y luego cargue la imagen desde el archivo tarball
podman load --input .\myems-api.tar

Step 3 myems-admin

En esta sección, instalará myems-admin en Podman.

  • Copie el código fuente al directorio raíz
cp -r myems/myems-admin /
cd /myems-admin
Precaución

Reemplace manualmente 127.0.0.1:8000 en nginx.conf con la IP y el puerto reales del HOST de myems-api

nano nginx.conf
      proxy_pass http://127.0.0.1:8000/;
  • Construya la imagen desde el código fuente
podman build -t myems/myems-admin .

Para compilar para múltiples plataformas y no solo para la arquitectura y el sistema operativo en el que se ejecuta el usuario que invoca la compilación. Puede usar buildx y establecer la bandera --platform para especificar la plataforma de destino para la salida de la compilación (por ejemplo, linux/amd64, linux/arm64 o darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-admin .
  • Ejecute un contenedor Podman

En el host, cree una carpeta compartida para archivos de subida:

mkdir /myems-upload

Cree un contenedor, monte la carpeta compartida de subida en el contenedor y también monte 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

Si desea migrar la imagen a otro equipo,

  • Exporte la imagen a un archivo tarball
podman save --output myems-admin.tar myems/myems-admin
  • Copie el archivo tarball a otro equipo y luego cargue la imagen desde el archivo tarball
podman load --input .\myems-admin.tar

Step 4 myems-modbus-tcp

En esta sección, instalará myems-modbus-tcp en Podman.

  • Copie el código fuente al directorio raíz
cp -r myems/myems-modbus-tcp /
cd /myems-modbus-tcp
  • Cree el archivo .env basado en el archivo example.env
Precaución

Reemplace manualmente 127.0.0.1 con la dirección IP real del HOST.

cp example.env .env
  • Construya la imagen desde el código fuente
podman build -t myems/myems-modbus-tcp .

Para compilar para múltiples plataformas y no solo para la arquitectura y el sistema operativo en el que se ejecuta el usuario que invoca la compilación. Puede usar buildx y establecer la bandera --platform para especificar la plataforma de destino para la salida de la compilación (por ejemplo, linux/amd64, linux/arm64 o darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-modbus-tcp .
  • Ejecute un contenedor Podman (como superusuario)
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

The absolute path before colon is for path on host and that may vary on your system. The absolute path after colon is for path on container and that CANNOT be changed. By passing .env as bind-mount parameter, you can change the configuration values later.

Si cambió el archivo .env, reinicie el contenedor para que el cambio surta efecto.

  • Migrar el contenedor Podman

Para migrar el contenedor a otro equipo,

  • Exporte la imagen a un archivo tarball
podman save --output myems-modbus-tcp.tar myems/myems-modbus-tcp
  • Copie el archivo tarball a otro equipo y luego cargue la imagen desde el archivo tarball
podman load --input .\myems-modbus-tcp.tar

Step 5 myems-cleaning

En esta sección, instalará myems-cleaning en Podman.

  • Copie el código fuente al directorio raíz
cp -r myems/myems-cleaning /
cd /myems-cleaning
  • Cree el archivo .env basado en el archivo example.env
Precaución

Reemplace manualmente 127.0.0.1 con la dirección IP real del HOST.

cp example.env .env
  • Construya la imagen desde el código fuente
podman build -t myems/myems-cleaning .

Para compilar para múltiples plataformas y no solo para la arquitectura y el sistema operativo en el que se ejecuta el usuario que invoca la compilación. Puede usar buildx y establecer la bandera --platform para especificar la plataforma de destino para la salida de la compilación (por ejemplo, linux/amd64, linux/arm64 o darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-cleaning .
  • Ejecute un contenedor Podman (como superusuario)
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

The absolute path before colon is for path on host and that may vary on your system. The absolute path after colon is for path on container and that CANNOT be changed. By passing .env as bind-mount parameter, you can change the configuration values later.

Si cambió el archivo .env, reinicie el contenedor para que el cambio surta efecto.

  • Migrar el contenedor Podman

Para migrar el contenedor a otro equipo,

  • Exporte la imagen a un archivo tarball
podman save --output myems-cleaning.tar myems/myems-cleaning
  • Copie el archivo tarball a otro equipo y luego cargue la imagen desde el archivo tarball
podman load --input .\myems-cleaning.tar

Step 6 myems-normalization

En esta sección, instalará myems-normalization en Podman.

  • Copie el código fuente al directorio raíz
cp -r myems/myems-normalization /
cd /myems-normalization
  • Cree el archivo .env basado en el archivo example.env
Precaución

Reemplace manualmente 127.0.0.1 con la dirección IP real del HOST.

cp example.env .env
  • Construya la imagen desde el código fuente
podman build -t myems/myems-normalization .

Para compilar para múltiples plataformas y no solo para la arquitectura y el sistema operativo en el que se ejecuta el usuario que invoca la compilación. Puede usar buildx y establecer la bandera --platform para especificar la plataforma de destino para la salida de la compilación (por ejemplo, linux/amd64, linux/arm64 o darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-normalization .
  • Ejecute un contenedor Podman (como superusuario)
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

The absolute path before colon is for path on host and that may vary on your system. The absolute path after colon is for path on container and that CANNOT be changed. By passing .env as bind-mount parameter, you can change the configuration values later.

Si cambió el archivo .env, reinicie el contenedor para que el cambio surta efecto.

  • Migrar el contenedor Podman

Para migrar el contenedor a otro equipo,

  • Exporte la imagen a un archivo tarball
podman save --output myems-normalization.tar myems/myems-normalization
  • Copie el archivo tarball a otro equipo y luego cargue la imagen desde el archivo tarball
podman load --input .\myems-normalization.tar

Step 7 myems-aggregation

En esta sección, instalará myems-aggregation en Podman.

  • Copie el código fuente al directorio raíz
cp -r myems/myems-aggregation /
cd /myems-aggregation
  • Cree el archivo .env basado en el archivo example.env
cp example.env .env
Precaución

Reemplace manualmente 127.0.0.1 con la dirección IP real del HOST.

  • Construya la imagen desde el código fuente
podman build -t myems/myems-aggregation .

Para compilar para múltiples plataformas y no solo para la arquitectura y el sistema operativo en el que se ejecuta el usuario que invoca la compilación. Puede usar buildx y establecer la bandera --platform para especificar la plataforma de destino para la salida de la compilación (por ejemplo, linux/amd64, linux/arm64 o darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-aggregation .
  • Ejecute un contenedor Podman (como superusuario)
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

The absolute path before colon is for path on host and that may vary on your system. The absolute path after colon is for path on container and that CANNOT be changed. By passing .env as bind-mount parameter, you can change the configuration values later.

Si cambió el archivo .env, reinicie el contenedor para que el cambio surta efecto.

  • Migrar el contenedor Podman

  • Exporte la imagen a un archivo tarball

podman save --output myems-aggregation.tar myems/myems-aggregation
  • Copie el archivo tarball a otro equipo y luego cargue la imagen desde el archivo tarball
podman load --input .\myems-aggregation.tar

Step 8 myems-web

En esta sección, instalará myems-web en Podman.

  • Modifique el archivo config.js:
Nota

Obtenga el mapboxToken en https://mapbox.com y luego establezca showOnlineMap en true. Si desea desactivar la función de mapa en línea, establezca showOnlineMap en false

cd myems/myems-web
nano src/config.js
Precaución

Reemplace 127.0.0.1:8000 en nginx.conf con la IP y el puerto reales del HOST de myems-api

cd myems/myems-web
nano nginx.conf
  • Copie el código fuente al directorio raíz
cp -r myems/myems-web /
cd /myems-web
Información

Puede ignorar de forma segura el comando 'npm run build' en esta sección, porque ya está incluido en el Podmanfile

  • Construya la imagen desde el código fuente
podman build -t myems/myems-web .

Para compilar para múltiples plataformas y no solo para la arquitectura y el sistema operativo en el que se ejecuta el usuario que invoca la compilación. Puede usar buildx y establecer la bandera --platform para especificar la plataforma de destino para la salida de la compilación (por ejemplo, linux/amd64, linux/arm64 o darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-web .
  • Ejecute un contenedor Podman

En el host, monte 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

Si desea migrar la imagen a otro equipo,

  • Exporte la imagen a un archivo tarball
podman save --output myems-web.tar myems/myems-web
  • Copie el archivo tarball a otro equipo y luego cargue la imagen desde el archivo tarball
podman load --input .\myems-web.tar

Post-instalación

¡Felicidades! Ahora puede iniciar sesión en la interfaz de administración y la interfaz web de MyEMS.

Puertos predeterminados

MyEMS Web UI: 80

MyEMS API: 8000

MyEMS Admin UI: 8001

Suponiendo que la dirección del servidor sea 192.168.1.8 (reemplace con la dirección real del servidor) Acceda a MyEMS Web UI en http://192.168.1.8 (el 80 se puede omitir) Acceda a MyEMS Admin UI en http://192.168.1.8:8001

Contraseñas predeterminadas

MyEMS Admin UI

Nombre de usuario:

administrator

Contraseña:

!MyEMS1

MyEMS Web UI

Nombre de usuario:

administrator@myems.io

Contraseña:

!MyEMS1

Solución de problemas