sqlitebrowser / dbhub.io

A "Cloud" for SQLite databases. Collaborative development for your data. 😊
https://dbhub.io
GNU Affero General Public License v3.0
372 stars 39 forks source link

Problem building Docker image #211

Closed Mictronics closed 1 year ago

Mictronics commented 1 year ago

https://github.com/sqlitebrowser/dbhub.io/blob/5c9e1ab1cfe0f59b25fb78a576c0cac429323cad/docker/Dockerfile#L2C5-L2C5 FROM alpine:3.17 needs to be set to FROM alpine:edgeto build Docker nowadays. (3.18 fails too) See my comments in previous issue #129

Mictronics commented 1 year ago

Some issues during build process. Causing pg server not running:

 * Creating a new PostgreSQL 15 database cluster ...could not change directory to "/var/lib/postgresql/15/data": Permission denied
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
....
initdb: error: could not access directory "/var/lib/postgresql/15/data": Permission denied
mv: can't rename '/var/lib/postgresql/15/data/postgresql.conf': No such file or directory
mv: can't rename '/var/lib/postgresql/15/data/pg_hba.conf': No such file or directory
mv: can't rename '/var/lib/postgresql/15/data/pg_ident.conf': No such file or directory
 [ !! ]
 * ERROR: postgresql failed to start
 * Starting rabbitmq ...
 * /run/rabbitmq: creating directory
 * /run/rabbitmq: correcting owner

 * /var/log/rabbitmq/startup_log: creating file
 * /var/log/rabbitmq/startup_log: correcting owner

 * /var/log/rabbitmq/startup_err: creating file
 * /var/log/rabbitmq/startup_err: correcting owner
 [ ok ]
createuser: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?
createdb: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?
psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?

And there is a general permission issue that prevents the output.log from being created.

-ash: can't create /home/dbhub/output.log: Permission denied

yarn docker:tail returns a file not exists error.

Mictronics commented 1 year ago

Modified the Docker file:

    echo "rm -rf /var/lib/postgresql/" >> /usr/local/bin/init.sh && \
    echo "createuser -U postgres -d dbhub" >> /usr/local/bin/init.sh && \
    echo "createdb -U postgres -O dbhub dbhub" >> /usr/local/bin/init.sh &&

init.sh seems to initialize the pg database now but pg server still fails to start:

docker exec -it dbhub-build ash /usr/local/bin/init.sh
 * Starting memcached ... [ ok ]
 * Starting MinIO ... [ ok ]
 * Creating a new PostgreSQL 15 database cluster ...The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with this locale configuration:
  provider:    icu
  ICU locale:  en-001-x-icu
  LC_COLLATE:  C
  LC_CTYPE:    C.UTF-8
  LC_MESSAGES: C
  LC_MONETARY: C
  LC_NUMERIC:  C
  LC_TIME:     C
The default text search configuration will be set to "english".

Data page checksums are enabled.

fixing permissions on existing directory /var/lib/postgresql/15/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success.

 [ ok ]
 * Starting PostgreSQL 15 ...pg_ctl: could not open PID file "/etc/postgresql/postmaster.pid": Permission denied

 * start-stop-daemon: failed to start `/usr/bin/pg_ctl'

 * Failed to start PostgreSQL 15
                                         [ !! ]
 * Check the log for a possible explanation of the above error:
 *     /var/log/postgresql/postmaster.log
 * ERROR: postgresql failed to start
 * Starting rabbitmq ...
 * /var/log/rabbitmq/startup_log: creating file

 * /var/log/rabbitmq/startup_err: creating file
 [ ok ]
createuser: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?
createdb: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?
psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
    Is the server running locally and accepting connections on that socket?
 * Stopping memcached ... [ ok ]
 * Stopping MinIO ... [ ok ]
 * WARNING: postgresql is already stopped
 * Stopping rabbitmq ...
 * /var/log/rabbitmq/shutdown_log: creating file

 * /var/log/rabbitmq/shutdown_err: creating file

 * start-stop-daemon: no matching processes found
 [ ok ]

Same when I try to start pg server manually:

docker exec -it dbhub-build rc-service postgresql start
 * Starting PostgreSQL 15 ...
pg_ctl: could not open PID file "/etc/postgresql/postmaster.pid": Permission denied
 * start-stop-daemon: failed to start `/usr/bin/pg_ctl'
 * Failed to start PostgreSQL 15                                                                                              [ !! ]
 * Check the log for a possible explanation of the above error:
 *     /var/log/postgresql/postmaster.log
 * ERROR: postgresql failed to start
Mictronics commented 1 year ago

Finally Docker builds, starts and runs. The Docker file right now:

# vim:set ft=dockerfile:
FROM alpine:edge

LABEL maintainer="Justin Clift <justin@postgresql.org>"

# Install Git, Go, Memcached, Minio, OpenRC, PostgreSQL, and RabbitMQ
RUN  \
    apk update && \
    apk upgrade && \
    apk add --no-cache ca-certificates 'curl>7.61.0' file nano git go libc-dev make memcached minio openrc openssl openssl-dev postgresql yarn && \
    apk add rabbitmq-server --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ && \
    rc-update add memcached default && \
    rc-update add minio default && \
    mkdir /run/postgresql && \
    chown postgres:postgres /run/postgresql && \
    su - postgres -c 'mkdir -p /var/lib/postgresql/15/data' && \
    su - postgres -c 'chmod 0700 /var/lib/postgresql/15/data' && \
    su - postgres -c 'initdb -D /var/lib/postgresql/15/data' && \
    su - postgres -c 'pg_ctl start -D /var/lib/postgresql/15/data' && \
    rc-update add rabbitmq-server default && \
    mkdir /etc/rabbitmq && \
    rabbitmq-plugins enable rabbitmq_management && \
    rabbitmq-plugins enable rabbitmq_top

# Create the DBHub.io OS user
RUN addgroup dbhub && \
    adduser -D -S -s /bin/ash -G dbhub dbhub

# Location of the DBHub.io source code
ENV DBHUB_SOURCE /dbhub.io

# Set Minio config variables
ENV MINIO_ROOT_USER minio
ENV MINIO_ROOT_PASSWORD minio123

RUN sed -i "s/^MINIO_ROOT_USER=\"change-me\"/MINIO_ROOT_USER=\"${MINIO_ROOT_USER}\"/" /etc/conf.d/minio && \
    sed -i "s/^MINIO_ROOT_PASSWORD=\"change-me\"/MINIO_ROOT_PASSWORD=\"${MINIO_ROOT_PASSWORD}\"/" /etc/conf.d/minio

# Run each of our daemon dependencies at least once to ensure they initialise ok, and populate the DBHub.io database
RUN echo "chown -R postgres:postgres /var/lib/postgresql/" >> /usr/local/bin/init.sh && \
    echo "chown -R postgres:postgres /run/postgresql" >> /usr/local/bin/init.sh && \
    echo "chown -R postgres:postgres /var/log/postgresql/" >> /usr/local/bin/init.sh && \
    echo "echo 'SomeDefaultRandomString01' > /var/lib/rabbitmq/.erlang.cookie" >> /usr/local/bin/init.sh && \
    echo "chmod 400 /var/lib/rabbitmq/.erlang.cookie" >> /usr/local/bin/init.sh && \
    echo "chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/" >> /usr/local/bin/init.sh && \
    echo "chown -R rabbitmq:rabbitmq /var/log/rabbitmq/" >> /usr/local/bin/init.sh && \
    echo "chown dbhub:dbhub /var/log/dbhub/" >> /usr/local/bin/init.sh && \
    echo "chown -R minio:minio /var/lib/minio/" >> /usr/local/bin/init.sh && \
    echo "openrc nonetwork" >> /usr/local/bin/init.sh && \
    echo "openrc default stop 2>&1 | grep -v 'Read-only file system'" >> /usr/local/bin/init.sh && \
    echo "su - postgres -c 'pg_ctl start -D /var/lib/postgresql/15/data'" >> /usr/local/bin/init.sh && \
    echo "createuser -U postgres -d dbhub" >> /usr/local/bin/init.sh && \
    echo "createdb -U postgres -O dbhub dbhub" >> /usr/local/bin/init.sh && \
    echo "su - dbhub -c 'psql dbhub < ${DBHUB_SOURCE}/database/dbhub.sql'" >> /usr/local/bin/init.sh && \
    echo "rc-service memcached stop 2>&1 | grep -v 'Read-only file system'" >> /usr/local/bin/init.sh && \
    echo "rc-service minio stop 2>&1 | grep -v 'Read-only file system'" >> /usr/local/bin/init.sh && \
    echo "rc-service postgresql stop 2>&1 | grep -v 'Read-only file system'" >> /usr/local/bin/init.sh && \
    echo "rc-service rabbitmq-server stop 2>&1 | grep -v 'Read-only file system'" >> /usr/local/bin/init.sh && \
    chmod +x /usr/local/bin/init.sh

# Set the dependencies and DBHub.io daemons to automatically start
ENTRYPOINT /usr/local/bin/start.sh

# Create directores for the DBHub daemons
RUN mkdir -p /var/log/dbhub /home/dbhub/.dbhub/disk_cache && \
    chown -R dbhub:dbhub /var/log/dbhub /home/dbhub/.dbhub/disk_cache && \
    chmod 700 /var/log/dbhub /home/dbhub/.dbhub/disk_cache

# DBHub.io config file
ENV CONFIG_FILE ${DBHUB_SOURCE}/docker/config.toml

# Build the Go debugger (Delve)
RUN GOBIN=/usr/local/bin go install github.com/go-delve/delve/cmd/dlv@latest

# Add script pieces for starting DBHub.io services
# These don't use openrc.  Not sure if it'd be useful.  Maybe a task for a different day?
RUN echo "echo 127.0.0.1 docker-dev.dbhub.io docker-dev >> /etc/hosts" >> /usr/local/bin/start.sh && \
    echo "chown -R postgres:postgres /var/lib/postgresql/" >> /usr/local/bin/start.sh && \
    echo "chown -R postgres:postgres /run/postgresql" >> /usr/local/bin/start.sh && \
    echo "chown -R postgres:postgres /var/log/postgresql/" >> /usr/local/bin/start.sh && \
    echo "echo 'SomeDefaultRandomString01' > /var/lib/rabbitmq/.erlang.cookie" >> /usr/local/bin/start.sh && \
    echo "chmod 400 /var/lib/rabbitmq/.erlang.cookie" >> /usr/local/bin/start.sh && \
    echo "chown -R rabbitmq:rabbitmq /var/lib/rabbitmq/" >> /usr/local/bin/start.sh && \
    echo "chown -R rabbitmq:rabbitmq /var/log/rabbitmq/" >> /usr/local/bin/start.sh && \
    echo "chown dbhub:dbhub /var/log/dbhub/" >> /usr/local/bin/start.sh && \
    echo "chown -R dbhub:dbhub /var/log/dbhub /home/dbhub/.dbhub/disk_cache" >> /usr/local/bin/start.sh && \
    echo "chmod 700 /var/log/dbhub /home/dbhub/.dbhub/disk_cache" >> /usr/local/bin/start.sh && \
    echo "chown -R minio:minio /var/lib/minio/" >> /usr/local/bin/start.sh && \
    echo "rc-service memcached stop"  >> /usr/local/bin/start.sh && \
    echo "rc-service minio stop"  >> /usr/local/bin/start.sh && \
    echo "rc-service rabbitmq-server stop"  >> /usr/local/bin/start.sh && \
    echo "rc-service postgresql start"  >> /usr/local/bin/start.sh && \
    echo "#openrc default" >> /usr/local/bin/start.sh && \
    echo "sleep 15" >> /usr/local/bin/start.sh && \
    echo "rc-service memcached start" >> /usr/local/bin/start.sh && \
    echo "rc-service minio start" >> /usr/local/bin/start.sh && \
    echo "rc-service postgresql start" >> /usr/local/bin/start.sh && \
    echo "rc-service rabbitmq-server start" >> /usr/local/bin/start.sh && \
    echo "" >> /usr/local/bin/start.sh && \
    echo "# Wait for RabbitMQ to start before launching the DBHub.io daemons" >> /usr/local/bin/start.sh && \
    echo "sleep 15" >> /usr/local/bin/start.sh && \
    echo "" >> /usr/local/bin/start.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} /usr/local/bin/dbhub-webui >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/start.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} /usr/local/bin/dbhub-api >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/start.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} /usr/local/bin/dbhub-db4s >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/start.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} /usr/local/bin/dbhub-live node1 /tmp/node1 >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/start.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} /usr/local/bin/dbhub-live node2 /tmp/node2 >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/start.sh && \
    echo "while :; do" >> /usr/local/bin/start.sh && \
    echo "  sleep 5" >> /usr/local/bin/start.sh && \
    echo "done" >> /usr/local/bin/start.sh && \
    chmod +x /usr/local/bin/start.sh

# Compile our own customised version of SQLite
RUN echo "Downloading SQLite source code" && \
    mkdir /sqlite && \
    cd /sqlite && \
    TARBALL=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 3) && \
    SHA3=$(curl -s https://sqlite.org/download.html | awk '/<!--/,/-->/ {print}' | grep 'sqlite-autoconf' | cut -d ',' -f 5) && \
    curl -LsS -o sqlite.tar.gz https://sqlite.org/${TARBALL} && \
    VERIFY=$(openssl dgst -sha3-256 sqlite.tar.gz | cut -d ' ' -f 2) && \
    if [ "$SHA3" != "$VERIFY" ]; then exit 1 ; fi && \
    if [ ! -f sqlite.tar.gz ]; then echo "Downloading the SQLite source code did not work" ; exit 3 ; fi && \
    echo "Compiling local SQLite" && \
    tar xfz sqlite.tar.gz && \
    cd sqlite-autoconf-* || exit 4 && \
    CPPFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_MAX_VARIABLE_NUMBER=250000 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_STAT4=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_SOUNDEX=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1 -DSQLITE_MAX_ATTACHED=125 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 -DSQLITE_ENABLE_SNAPSHOT=1" ./configure --prefix=/sqlite --enable-dynamic-extensions=no && \
    make -j9 && \
    make install && \
    cd .. && \
    rm -rf sqlite-autoconf-* && \
    echo "/sqlite/lib:/lib:/usr/local/lib:/usr/lib" > /etc/ld-musl-x86_64.path

# Create script to compile DBHub.io daemons
RUN echo "cd ${DBHUB_SOURCE}" >> /usr/local/bin/compile.sh && \
    echo "yarn" >> /usr/local/bin/compile.sh && \
    echo "yarn run babel ${DBHUB_SOURCE}/webui/jsx --out-dir ${DBHUB_SOURCE}/webui/js --presets babel-preset-react-app/prod" >> /usr/local/bin/compile.sh && \
    echo "yarn run webpack -c ${DBHUB_SOURCE}/webui/webpack.config.js" >> /usr/local/bin/compile.sh && \
    echo "cd ${DBHUB_SOURCE}/api" >> /usr/local/bin/compile.sh && \
    echo "PKG_CONFIG_PATH=/sqlite/lib/pkgconfig go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-api ." >> /usr/local/bin/compile.sh && \
    echo "cd ${DBHUB_SOURCE}/db4s" >> /usr/local/bin/compile.sh && \
    echo "PKG_CONFIG_PATH=/sqlite/lib/pkgconfig go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-db4s ." >> /usr/local/bin/compile.sh && \
    echo "cd ${DBHUB_SOURCE}/live" >> /usr/local/bin/compile.sh && \
    echo "PKG_CONFIG_PATH=/sqlite/lib/pkgconfig go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-live ." >> /usr/local/bin/compile.sh && \
    echo "cd ${DBHUB_SOURCE}/standalone/analysis" >> /usr/local/bin/compile.sh && \
    echo "PKG_CONFIG_PATH=/sqlite/lib/pkgconfig go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-analysis ." >> /usr/local/bin/compile.sh && \
    echo "ln -f -s /usr/local/bin/dbhub-analysis  /etc/periodic/15min/" >> /usr/local/bin/compile.sh && \
    echo "cd ${DBHUB_SOURCE}/webui" >> /usr/local/bin/compile.sh && \
    echo "PKG_CONFIG_PATH=/sqlite/lib/pkgconfig go build -gcflags \"all=-N -l\" -buildvcs=false -o /usr/local/bin/dbhub-webui ." >> /usr/local/bin/compile.sh && \
    echo "/usr/local/bin/restart.sh" >> /usr/local/bin/compile.sh && \
    chmod +x /usr/local/bin/compile.sh

# Create script to restart the DBHub.io webui and api daemons
RUN echo "# Kill the existing running daemons" >> /usr/local/bin/restart.sh && \
    echo "pkill dbhub-webui" >> /usr/local/bin/restart.sh && \
    echo "pkill dbhub-api" >> /usr/local/bin/restart.sh && \
    echo "pkill dbhub-db4s" >> /usr/local/bin/restart.sh && \
    echo "pkill dbhub-live" >> /usr/local/bin/restart.sh && \
    echo "pkill dlv" >> /usr/local/bin/restart.sh && \
    echo "" >> /usr/local/bin/restart.sh && \
    echo "# Restart the daemons" >> /usr/local/bin/restart.sh && \
    echo "chown -R dbhub: /home/dbhub/.dbhub" >> /usr/local/bin/restart.sh && \
    echo "if [ -c /dev/console ]; then" >> /usr/local/bin/restart.sh && \
    echo "  chmod o+w /dev/console" >> /usr/local/bin/restart.sh && \
    echo "fi" >> /usr/local/bin/restart.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} nohup /usr/local/bin/dbhub-webui >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/restart.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} nohup /usr/local/bin/dbhub-api >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/restart.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} nohup /usr/local/bin/dbhub-db4s >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/restart.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} nohup /usr/local/bin/dbhub-live node1 /tmp/node1 >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/restart.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} nohup /usr/local/bin/dbhub-live node2 /tmp/node2 >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/restart.sh && \
    echo "" >> /usr/local/bin/restart.sh && \
    echo "# Delay long enough for the DBHub.io daemons to start" >> /usr/local/bin/restart.sh && \
    echo "sleep 1" >> /usr/local/bin/restart.sh && \
    chmod +x /usr/local/bin/restart.sh

# Create script to start the DBHub.io webui and api daemons using the Go debugger (Delve)
RUN echo "# Kill the existing running daemons" >> /usr/local/bin/debug.sh && \
    echo "pkill dbhub-webui" >> /usr/local/bin/debug.sh && \
    echo "pkill dbhub-api" >> /usr/local/bin/debug.sh && \
    echo "pkill dbhub-db4s" >> /usr/local/bin/debug.sh && \
    echo "pkill dbhub-live" >> /usr/local/bin/debug.sh && \
    echo "pkill dlv" >> /usr/local/bin/debug.sh && \
    echo "" >> /usr/local/bin/debug.sh && \
    echo "# Restart the daemons" >> /usr/local/bin/debug.sh && \
    echo "chown dbhub: /home/dbhub/.dbhub" >> /usr/local/bin/debug.sh && \
    echo "if [ -c /dev/console ]; then" >> /usr/local/bin/debug.sh && \
    echo "  chmod o+w /dev/console" >> /usr/local/bin/debug.sh && \
    echo "fi" >> /usr/local/bin/debug.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} nohup dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/dbhub-webui >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/debug.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} nohup dlv --listen=:2346 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/dbhub-api >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/debug.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} nohup dlv --listen=:2347 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/dbhub-db4s >>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/debug.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} nohup dlv --listen=:2348 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/dbhub-live node1 /tmp/node1>>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/debug.sh && \
    echo "su - dbhub -c 'if [ -f "${DBHUB_SOURCE}/.env" ]; then source ${DBHUB_SOURCE}/.env; fi; CONFIG_FILE=${CONFIG_FILE} nohup dlv --listen=:2349 --headless=true --api-version=2 --accept-multiclient exec /usr/local/bin/dbhub-live node2 /tmp/node2>>/var/log/dbhub/output.log 2>&1 &'" >> /usr/local/bin/debug.sh && \
    echo "" >> /usr/local/bin/debug.sh && \
    echo "# Delay long enough for the DBHub.io daemons to start" >> /usr/local/bin/debug.sh && \
    echo "sleep 1" >> /usr/local/bin/debug.sh && \
    chmod +x /usr/local/bin/debug.sh

# Build the DBHub.io daemons
RUN cd / && git clone --branch master --depth 5 https://github.com/sqlitebrowser/dbhub.io
RUN /usr/local/bin/compile.sh

# Populate the DBHub.io database
WORKDIR /usr/local/bin
RUN init.sh

There are probably better or more efficient solutions but at least is works. There is a big mess with all the different user permissions involved.

Working with Ubuntu server 22.04.3 LTS (GNU/Linux 5.15.0-79-generic x86_64) in VMBox.

Mictronics commented 1 year ago

How to setup dbhub.io on a fresh Alpine Linux: https://www.mictronics.de/posts/dbhub_io/