MacでRefBox – その2

MacでRefBoxにて,「ただ単に,screen の-rオプションに対応していないだけなので,そこを修正したら動くようになる」ので,その方法で対応してみるためのメモ.
というか,今,試してみたら,いけたかも.

export REFBOX_COMPOSE_COMMAND=docker-compose

このまま実行すると,以下のエラーがでます.

wataru@Mac-mini-3 rcll-get-started % ./setup.sh
Starting refbox
./setup.sh: line 124: docker-compose: command not found

docker-compose ってコマンドがないってことで,今はdockerコマンドのcomposeオプションになっています.
そこで,「-」を取って対応してみると,

export REFBOX_COMPOSE_COMMAND=docker compose

以下のエラーが出ます.

wataru@Mac-mini-3 rcll-get-started % ./setup.sh 
Starting refbox
unknown shorthand flag: 'f' in -f

Usage:  docker [OPTIONS] COMMAND [ARG...]

Run 'docker --help' for more information
Use: screen [-opts] [cmd [args]] or: screen -r [host.tty] Options: -a Force all capabilities into each window's termcap. -A -[r|R] Adapt all windows to the new display width & height. -c file Read configuration file instead of '.screenrc'. -d (-r) Detach the elsewhere running screen (and reattach here). -dmS name Start as daemon: Screen session in detached mode. -D (-r) Detach and logout remote (and reattach here). -D -RR Do whatever is needed to get a screen session. -e xy Change command characters. -f Flow control on, -fn = off, -fa = auto. -h lines Set the size of the scrollback history buffer. -i Interrupt output sooner when flow control is on. -list or -ls. Do nothing, just list our SockDir. -L Turn on output logging. -m ignore $STY variable, do create a new screen session. -O Choose optimal output rather than exact vt100 emulation. -p window Preselect the named window if it exists. -q Quiet startup. Exits with non-zero return code if unsuccessful. -r Reattach to a detached screen process. -R Reattach if possible, otherwise start a new session. -s shell Shell to execute rather than $SHELL. -S sockname Name this session <pid>.sockname instead of <pid>.<tty>.<host>. -t title Set title. (window's name). -T term Use term as $TERM for windows, rather than "screen". -U Tell screen to use UTF-8 encoding. -v Print "Screen version 4.00.03 (FAU) 23-Oct-06". -wipe Do nothing, just clean up SockDir. -x Attach to a not detached screen. (Multi display mode). -X Execute <cmd> as a screen command in the specified session. Error: Unknown option -Q
Setting up screen tab refbox
screen -S rcll -X screen -t refbox docker -f /Users/wataru/git/rcll-get-started/compose_files/refbox.yaml logs -f

これをscreenのエラー(オプションfがおかしい)と思っていたのですが,dockerコマンド側でのエラーでした(usageを見たら,そうなっていますね).
で,何がおかしかったかと言うと,コマンドの与え方でした.

export REFBOX_COMPOSE_COMMAND="docker compose"

ダブルクォーテーションで囲んだら,通りました.
で,このままだとweb上のrefboxのコンテナイメージを取ってきちゃいますので,MacでRefBoxの作業をして,refboxのコンテナをbuildしましょう.

mkdir -p ~/Documents/git
cd ~/Documents/git
git clone https://github.com/robocup-logistics/rcll-refbox
cd rcll-refbox
wataru@MacBook-Air-3 rcll-refbox % grep -n1 "platform=linux/x86_64" Dockerfile
10-
11:FROM --platform=linux/x86_64 fedora:40 as builder
12-RUN   dnf update -y --refresh && dnf install -y --nodocs 'dnf-command(copr)' && \
--
82-
83:FROM --platform=linux/x86_64 fedora:40 as refbox
84-RUN   dnf update -y --refresh && dnf install -y --nodocs 'dnf-command(copr)' && \
docker build -t rcll-refbox .
docker run -t rcll-refbox

build して実行したらコンテナを確認.

wataru@Mac-mini-3 rcll-refbox % docker ps
CONTAINER ID   IMAGE                                                   COMMAND                  CREATED             STATUS                  PORTS                                     NAMES
45bf49e4a93b   rcll-refbox                                             "refbox"                 3 seconds ago       Up 2 seconds                                                      determined_pascal
9853a8ec1b16   quay.io/robocup-logistics/rcll-refbox-frontend:latest   "httpd-foreground"       About an hour ago   Up About an hour        0.0.0.0:8080->80/tcp, [::]:8080->80/tcp   refbox-frontend
1ec19996ea51   sharelatex/sharelatex:5.5.4                             "/sbin/my_init"          3 weeks ago         Up 20 hours             127.0.0.1:80->80/tcp                      sharelatex
be3c316ab965   redis:6.2                                               "docker-entrypoint.s…"   3 weeks ago         Up 20 hours             6379/tcp                                  redis
7351cd00af49   mongo:6.0                                               "docker-entrypoint.s…"   3 weeks ago         Up 20 hours (healthy)   27017/tcp                                 mongo

rcll-refbox として動いているのが確認できます.
で,これをcompose-file/refbox.yaml で読み取る形になります.

  refbox:
    container_name: refbox
    image: "${REFBOX_IMAGE}:${REFBOX_TAG}"

そのため,setup.sh のREFBOX_IMAGEを以下のように変更します.

# export REFBOX_IMAGE=quay.io/robocup-logistics/rcll-refbox
export REFBOX_IMAGE=rcll-refbox

で,setup.sh を実行したら,mongodb-checkのコンテナーの読み込みでエラーが出るっぽい….

wataru@Mac-mini-3 rcll-get-started % cat compose_files/refbox.yaml 
version: '3.7'
# name: refbox-compose
services:
  mongodb-check:
    container_name: mongodb-check
    image: ${MONGODB_IMAGE}:${MONGODB_TAG}
    command: ["sh", "-c", "mongosh ${RC_MONGODB_URI} --eval 'printjson(db.serverStatus())' || (sleep 1; exit -1)"]
    network_mode: "host"
    restart: on-failure:10

これですよねぇ.
setup.sh 的には,

export MONGODB_TAG=7.0
...
export MONGODB_IMAGE=docker.io/library/mongo

となっています.
latestだったら取ってくれるのになぁ.
mongo:7.0かなぁ.
linux arm v8があるなぁ.

wataru@Mac-mini-3 rcll-get-started % docker run docker.io/library/mongo
Unable to find image 'mongo:latest' locally
latest: Pulling from library/mongo
beda47828643: Pull complete 
f841815c6988: Pull complete 
cc43ec4c1381: Pull complete 
791918c13104: Pull complete 
9d5286ced06d: Pull complete 
b1abc0514d8e: Pull complete 
4b43425e165b: Pull complete 
5e3fe511aefa: Pull complete 
Digest: sha256:c75092233f998275c7b2c3942bb897994adb709bc5b9b7d043cc642ec521b6c7
Status: Downloaded newer image for mongo:latest

色々とやった結果.


動きました.
明日,まとめのブログを書きます.

wataru@Mac-mini-3 rcll-get-started % git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	deleted:    compose_files/mongodb.yaml
	modified:   compose_files/refbox.yaml
	modified:   config/refbox/comm/default_comm.yaml
	modified:   config/refbox/mongodb/default_mongodb.yaml
	modified:   config/refbox/mongodb/enable_mongodb.yaml
	typechange: setup.sh

↑enable_mongodb.yaml はたぶん関係ない.

wataru@Mac-mini-3 rcll-get-started % git diff compose_files/refbox.yaml
diff --git a/compose_files/refbox.yaml b/compose_files/refbox.yaml
index 1d93d85..004b3c4 100644
--- a/compose_files/refbox.yaml
+++ b/compose_files/refbox.yaml
@@ -1,17 +1,30 @@
 version: '3.7'
 # name: refbox-compose
 services:
+  mongodb:
+    container_name: "mongodb"
+    # network_mode: "host"
+    image: ${MONGODB_IMAGE}:${MONGODB_TAG}
+    restart: "no"
+    command: mongod --port ${RC_MONGODB_PORT}
+    volumes:
+      - '${RC_MONGODB_DATA_DIR}:/data:z'
+
   mongodb-check:
     container_name: mongodb-check
     image: ${MONGODB_IMAGE}:${MONGODB_TAG}
-    command: ["sh", "-c", "mongosh ${RC_MONGODB_URI} --eval 'printjson(db.serverStatus())' || (sleep 1; exit -1)"]
-    network_mode: "host"
+    command: ["sh", "-c", "mongosh ${RC_MONGODB_URI} --eval 'printjson(db.serverStatus())' || (sleep 1; exit 1)"]
+    # network_mode: "host"
+    depends_on:
+      - mongodb
     restart: on-failure:10
 
   refbox:
     container_name: refbox
     image: "${REFBOX_IMAGE}:${REFBOX_TAG}"
-    network_mode: "host"
+    # network_mode: "host"
+    ports:
+      - 1234:1234
     depends_on:
       mongodb-check:
         condition: service_completed_successfully
@@ -25,7 +38,7 @@ services:
     container_name: refbox-frontend
     image: "${REFBOX_FRONTEND_IMAGE}:${REFBOX_FRONTEND_TAG}"
     ports:
-      - 8080:80
+      - 6080:80
     volumes:
       - /var/tmp/${USER}:/usr/local/apache2/logs/:z
     restart: on-failure:10

exit -1 => 1 も本質ではなかったはず.

wataru@Mac-mini-3 rcll-get-started % git diff config/refbox/comm/default_comm.yaml 
diff --git a/config/refbox/comm/default_comm.yaml b/config/refbox/comm/default_comm.yaml
index 15a6abd..bf03fad 100644
--- a/config/refbox/comm/default_comm.yaml
+++ b/config/refbox/comm/default_comm.yaml
@@ -20,21 +20,24 @@ llsfrb:
     # Do not specify both!
     public-peer:
       # host: !ipv4 192.168.122.255
-      host: !ipv4 172.26.255.255
+      # host: !ipv4 172.26.255.255
+      host: !ipv4 127.0.0.1
       # port: !udp-port 4444
       send-port: !udp-port 4444
       recv-port: !udp-port 4445
 
     cyan-peer:
       # host: !ipv4 192.168.122.255
-      host: !ipv4 172.26.255.255
+      # host: !ipv4 172.26.255.255
+      host: !ipv4 127.0.0.1
       # port: !udp-port 4441
       send-port: !udp-port 4441
       recv-port: !udp-port 4446
 
     magenta-peer:
       # host: !ipv4 192.168.122.255
-      host: !ipv4 172.26.255.255
+      # host: !ipv4 172.26.255.255
+      host: !ipv4 127.0.0.1
       # port: !udp-port 4442
       send-port: !udp-port 4442
       recv-port: !udp-port 4447

↑これは定番の変更ですね.

wataru@Mac-mini-3 rcll-get-started % git diff config/refbox/mongodb/default_mongodb.yaml 
diff --git a/config/refbox/mongodb/default_mongodb.yaml b/config/refbox/mongodb/default_mongodb.yaml
index 0cb64ee..35f7381 100644
--- a/config/refbox/mongodb/default_mongodb.yaml
+++ b/config/refbox/mongodb/default_mongodb.yaml
@@ -6,7 +6,7 @@
 llsfrb:
   mongodb:
     enable: true
-    hostport: localhost
+    hostport: mongodb
     collections:
       text-log: log
       clips-log: clipslog

↑これは重要だった.

wataru@Mac-mini-3 rcll-get-started % git diff setup.sh 
diff --git a/setup.sh b/setup.sh
index eb01703..2e6a9d1 100755
--- a/setup.sh
+++ b/setup.sh
@@ -10,14 +10,15 @@ fi
 export REFBOX_FRONTEND_TAG=latest
 export REFBOX_TAG=latest
 export MONGODB_BACKEND_TAG=latest
-export MONGODB_TAG=7.0
+export MONGODB_TAG=latest
 export MQTT_BRIDGE_TAG=master
 export MQTT_BROKER_TAG=latest
 export SIMULATOR_TAG=latest
 
 # Source URLs to obtain the container images from
 export REFBOX_FRONTEND_IMAGE=quay.io/robocup-logistics/rcll-refbox-frontend
-export REFBOX_IMAGE=quay.io/robocup-logistics/rcll-refbox
+# export REFBOX_IMAGE=quay.io/robocup-logistics/rcll-refbox
+export REFBOX_IMAGE=rcll-refbox
 export MONGODB_BACKEND_IMAGE=quay.io/robocup-logistics/mongodb-backend
 export MONGODB_IMAGE=docker.io/library/mongo
 export MQTT_BRIDGE_IMAGE=ghcr.io/robocup-logistics/rcll-mqtt-bridge
@@ -28,7 +29,7 @@ export SIMULATOR_IMAGE=quay.io/robocup-logistics/rcll-simulator
 export REFBOX_LOGS_DIR=$rcll_get_started_dir/logs
 
 # compose command (change in case you use alternative tools like podman
-export REFBOX_COMPOSE_COMMAND=docker-compose
+export REFBOX_COMPOSE_COMMAND="docker compose"
 
 # location of config files
 export REFBOX_CONFIG=./../config/refbox
@@ -56,8 +57,10 @@ export RC_SIMULATOR_START=false
 export RC_SCREEN_NAME=rcll
 
 export RC_MONGODB_PORT=27017
-export RC_MONGODB_HOST=localhost
+# export RC_MONGODB_HOST=localhost
+export RC_MONGODB_HOST=mongodb
 export RC_MONGODB_URI=mongodb://${RC_MONGODB_HOST}:${RC_MONGODB_PORT}
+
 export RC_MONGODB_BACKEND_DB_NAME=rcll
 
 export RC_MQTT_BROKER=tcp://localhost:1883
@@ -100,6 +103,7 @@ function rc_add_to_screen() {
   rc_setup_screen
   rc_clear_screen_tabs $1
   echo "Setting up screen tab $1"
+  echo "screen -S ${RC_SCREEN_NAME} -X screen -t "$1" ${REFBOX_COMPOSE_COMMAND} -f ${rcll_compose_files_dir}/$1.yaml logs -f"
   screen -S ${RC_SCREEN_NAME} -X screen -t "$1" ${REFBOX_COMPOSE_COMMAND} -f ${rcll_compose_files_dir}/$1.yaml logs -f
 }

↑明日,まとめます.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

*