Pergi ke konten utama

Podman on Linux

Dalam panduan ini, Anda akan melakukan deploy MyEMS dengan Podman di Linux.

Prasyarat

  • Podman dan npm telah terinstal di host.
  • Server MySQL telah terinstal.
  • Database MySQL dapat diakses dari host tempat Podman Engine berjalan.
Peringatan
  • Disarankan menggunakan hak akses root untuk menjalankan perintah podman.

  • Setelah menginstal podman, gunakan perintah systemctl status podman-restart.service untuk memeriksa apakah kontainer dikonfigurasi untuk otomatis mulai dan kebijakan. Jika muncul Unit not found, berarti kontainer tidak dapat otomatis mulai.

Langkah 1 Database

Lihat Database

Langkah 2 myems-api

Pada bagian ini, Anda akan menginstal myems-api di Podman.

  • Copy source code to root directory
cp -r myems/myems-api /
cd /myems-api
  • Buat file .env berdasarkan file example.env
Peringatan

Ganti manual 127.0.0.1 dengan alamat IP HOST yang sebenarnya.

cp example.env .env
  • Build Image from Source Code
podman build -t myems/myems-api .

Untuk membangun untuk banyak platform dan tidak hanya arsitektur serta sistem operasi yang digunakan oleh pengguna saat menjalankan build. Anda dapat menggunakan buildx dan mengatur flag --platform untuk menentukan platform target output build, (misal: linux/amd64, linux/arm64, atau darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-api .
  • Run a Podman container

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

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.

If you want to immigrate the image to another computer,

  • Export image to tarball file
podman save --output myems-api.tar myems/myems-api
  • Copy the tarball file to another computer, and then load image from tarball file
podman load --input .\myems-api.tar

Langkah 3 myems-admin

Pada bagian ini, Anda akan menginstal myems-admin di Podman.

  • Copy source code to root directory
cp -r myems/myems-admin /
cd /myems-admin
Peringatan

Ganti manual 127.0.0.1:8000 di nginx.conf dengan IP dan port HOST myems-api yang sebenarnya

nano nginx.conf
      proxy_pass http://127.0.0.1:8000/;
  • Build Image from Source Code
podman build -t myems/myems-admin .

Untuk membangun untuk banyak platform dan tidak hanya arsitektur serta sistem operasi yang digunakan oleh pengguna saat menjalankan build. Anda dapat menggunakan buildx dan mengatur flag --platform untuk menentukan platform target output build, (misal: linux/amd64, linux/arm64, atau darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-admin .
  • Run a Podman container

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

If you want to immigrate the image to another computer,

  • Export image to tarball file
podman save --output myems-admin.tar myems/myems-admin
  • Copy the tarball file to another computer, and then load image from tarball file
podman load --input .\myems-admin.tar

Langkah 4 myems-modbus-tcp

Pada bagian ini, Anda akan menginstal myems-modbus-tcp di Podman.

  • Copy source code to root directory
cp -r myems/myems-modbus-tcp /
cd /myems-modbus-tcp
  • Buat file .env berdasarkan file example.env
Peringatan

Ganti manual 127.0.0.1 dengan alamat IP HOST yang sebenarnya.

cp example.env .env
  • Build Image from Source Code
podman build -t myems/myems-modbus-tcp .

Untuk membangun untuk banyak platform dan tidak hanya arsitektur serta sistem operasi yang digunakan oleh pengguna saat menjalankan build. Anda dapat menggunakan buildx dan mengatur flag --platform untuk menentukan platform target output build, (misal: linux/amd64, linux/arm64, atau darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-modbus-tcp .
  • Run a Podman container (run as superuser)
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. If you changed .env file, restart the container to make the change effective.

  • Immigrate the Podman container

To immigrate the container to another computer,

  • Export image to tarball file
podman save --output myems-modbus-tcp.tar myems/myems-modbus-tcp
  • Copy the tarball file to another computer, and then load image from tarball file
podman load --input .\myems-modbus-tcp.tar

Langkah 5 myems-cleaning

Pada bagian ini, Anda akan menginstal myems-cleaning di Podman.

  • Copy source code to root directory
cp -r myems/myems-cleaning /
cd /myems-cleaning
  • Buat file .env berdasarkan file example.env
Peringatan

Ganti manual 127.0.0.1 dengan alamat IP HOST yang sebenarnya.

cp example.env .env
  • Build Image from Source Code
podman build -t myems/myems-cleaning .

Untuk membangun untuk banyak platform dan tidak hanya arsitektur serta sistem operasi yang digunakan oleh pengguna saat menjalankan build. Anda dapat menggunakan buildx dan mengatur flag --platform untuk menentukan platform target output build, (misal: linux/amd64, linux/arm64, atau darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-cleaning .
  • Run a Podman container (run as superuser)
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. If you changed .env file, restart the container to make the change effective.

  • Immigrate the Podman container

To immigrate the container to another computer,

  • Export image to tarball file
podman save --output myems-cleaning.tar myems/myems-cleaning
  • Copy the tarball file to another computer, and then load image from tarball file
podman load --input .\myems-cleaning.tar

Langkah 6 myems-normalization

Pada bagian ini, Anda akan menginstal myems-normalization di Podman.

  • Copy source code to root directory
cp -r myems/myems-normalization /
cd /myems-normalization
  • Buat file .env berdasarkan file example.env
Peringatan

Ganti manual 127.0.0.1 dengan alamat IP HOST yang sebenarnya.

cp example.env .env
  • Build Image from Source Code
podman build -t myems/myems-normalization .

Untuk membangun untuk banyak platform dan tidak hanya arsitektur serta sistem operasi yang digunakan oleh pengguna saat menjalankan build. Anda dapat menggunakan buildx dan mengatur flag --platform untuk menentukan platform target output build, (misal: linux/amd64, linux/arm64, atau darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-normalization .
  • Run a Podman container (run as superuser)
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. If you changed .env file, restart the container to make the change effective.

  • Immigrate the Podman container

To immigrate the container to another computer,

  • Export image to tarball file
podman save --output myems-normalization.tar myems/myems-normalization
  • Copy the tarball file to another computer, and then load image from tarball file
podman load --input .\myems-normalization.tar

Langkah 7 myems-aggregation

Pada bagian ini, Anda akan menginstal myems-aggregation di Podman.

  • Copy source code to root directory
cp -r myems/myems-aggregation /
cd /myems-aggregation
  • Create .env file based on example.env file
cp example.env .env
Peringatan

Ganti manual 127.0.0.1 dengan alamat IP HOST yang sebenarnya.

  • Build Image from Source Code
podman build -t myems/myems-aggregation .

Untuk membangun untuk banyak platform dan tidak hanya arsitektur serta sistem operasi yang digunakan oleh pengguna saat menjalankan build. Anda dapat menggunakan buildx dan mengatur flag --platform untuk menentukan platform target output build, (misal: linux/amd64, linux/arm64, atau darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-aggregation .
  • Run a Podman container (run as superuser)
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. If you changed .env file, restart the container to make the change effective.

  • Immigrate the Podman container

  • Export image to tarball file

podman save --output myems-aggregation.tar myems/myems-aggregation
  • Copy the tarball file to another computer, and then load image from tarball file
podman load --input .\myems-aggregation.tar

Langkah 8 myems-web

Pada bagian ini, Anda akan menginstal myems-web di Podman.

  • Modify the config.js file:
Catatan

Dapatkan mapboxToken di https://mapbox.com lalu atur showOnlineMap ke true. Jika Anda ingin mematikan fitur peta online, atur showOnlineMap ke false

cd myems/myems-web
nano src/config.js
Peringatan

Ganti 127.0.0.1:8000 di nginx.conf dengan IP dan port HOST myems-api yang sebenarnya

cd myems/myems-web
nano nginx.conf
  • Copy source code to root directory
cp -r myems/myems-web /
cd /myems-web
Informasi

Anda dapat mengabaikan perintah 'npm run build' di bagian ini, karena sudah termasuk dalam Podmanfile

  • Build Image from Source Code
podman build -t myems/myems-web .

Untuk membangun untuk banyak platform dan tidak hanya arsitektur serta sistem operasi yang digunakan oleh pengguna saat menjalankan build. Anda dapat menggunakan buildx dan mengatur flag --platform untuk menentukan platform target output build, (misal: linux/amd64, linux/arm64, atau darwin/amd64).

podman buildx build --platform=linux/amd64 -t myems/myems-web .
  • Run a Podman container

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

If you want to immigrate the image to another computer,

  • Export image to tarball file
podman save --output myems-web.tar myems/myems-web
  • Copy the tarball file to another computer, and then load image from tarball file
podman load --input .\myems-web.tar

Setelah Instalasi

Selamat! Anda sekarang dapat masuk ke MyEMS Admin UI dan Web UI.

Port Default

MyEMS Web UI: 80

MyEMS API: 8000

MyEMS Admin UI: 8001

Misalkan alamat server adalah 192.168.1.8 (ganti dengan alamat server yang sebenarnya) Akses MyEMS Web UI di http://192.168.1.8 (port 80 dapat diabaikan) Akses MyEMS Admin UI di http://192.168.1.8:8001

Password Default

MyEMS Admin UI

Nama Pengguna:

administrator

Kata Sandi:

!MyEMS1

MyEMS Web UI

Nama Pengguna:

administrator@myems.io

Kata Sandi:

!MyEMS1

Pemecahan Masalah