From 37fc334c4601dea4e165c38d40a2335a49cd2306 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 18 May 2022 13:09:42 -0400 Subject: [PATCH] update docker and entrypoints --- docker/Dockerfile => Dockerfile | 6 +++--- docker/docker-compose.yml | 4 ++-- docker/hooks/build | 7 ------- docker/hub-compose.yml | 4 ++-- hub/herald/__main__.py | 4 ++-- scripts/deploy_scribe_dev.sh | 2 +- docker/scribe_entrypoint.sh => scripts/entrypoint.sh | 6 +++--- {docker => scripts}/set_build.py | 0 setup.py | 6 +++--- 9 files changed, 16 insertions(+), 23 deletions(-) rename docker/Dockerfile => Dockerfile (90%) delete mode 100644 docker/hooks/build rename docker/scribe_entrypoint.sh => scripts/entrypoint.sh (52%) rename {docker => scripts}/set_build.py (100%) diff --git a/docker/Dockerfile b/Dockerfile similarity index 90% rename from docker/Dockerfile rename to Dockerfile index e72a8bb..f62dbe6 100644 --- a/docker/Dockerfile +++ b/Dockerfile @@ -28,19 +28,19 @@ RUN groupadd -g 999 $user && useradd -m -u 999 -g $user $user RUN mkdir -p $db_dir RUN chown -R $user:$user $db_dir -COPY . $projects_dir +COPY docker $projects_dir RUN chown -R $user:$user $projects_dir USER $user WORKDIR $projects_dir RUN python3.9 -m pip install pip RUN python3.9 -m pip install -e . -RUN python3.9 docker/set_build.py +RUN python3.9 scripts/set_build.py RUN rm ~/.cache -rf # entry point VOLUME $db_dir ENV DB_DIRECTORY=$db_dir -COPY ./docker/scribe_entrypoint.sh /entrypoint.sh +COPY ./scripts/entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 3d4f617..6f6d321 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -55,8 +55,8 @@ services: volumes: - "lbry_rocksdb:/database" environment: - - HUB_COMMAND=scribe-hub - command: # for full options, see `scribe-hub --help` + - HUB_COMMAND=herald + command: # for full options, see `herald --help` - "--daemon_url=http://lbry:lbry@127.0.0.1:9245" - "--max_query_workers=4" - "--host=0.0.0.0" diff --git a/docker/hooks/build b/docker/hooks/build deleted file mode 100644 index 371640d..0000000 --- a/docker/hooks/build +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd "$DIR/../.." ## make sure we're in the right place. Docker Hub screws this up sometimes -echo "docker build dir: $(pwd)" - -docker build --build-arg DOCKER_TAG=$DOCKER_TAG --build-arg DOCKER_COMMIT=$SOURCE_COMMIT -f $DOCKERFILE_PATH -t $IMAGE_NAME . diff --git a/docker/hub-compose.yml b/docker/hub-compose.yml index cd61138..9038984 100644 --- a/docker/hub-compose.yml +++ b/docker/hub-compose.yml @@ -34,7 +34,7 @@ services: - "--max_query_workers=2" - "--filtering_channel_ids=770bd7ecba84fd2f7607fb15aedd2b172c2e153f 95e5db68a3101df19763f3a5182e4b12ba393ee8" - "--blocking_channel_ids=dd687b357950f6f271999971f43c785e8067c3a9 06871aa438032244202840ec59a469b303257cad b4a2528f436eca1bf3bf3e10ff3f98c57bd6c4c6" - scribe_hub: + herald: depends_on: - scribe_elastic_sync - scribe @@ -47,7 +47,7 @@ services: volumes: - "lbry_rocksdb:/database" environment: - - HUB_COMMAND=scribe-hub + - HUB_COMMAND=herald command: - "--daemon_url=http://lbry:lbry@127.0.0.1:9245" - "--elastic_host=127.0.0.1" diff --git a/hub/herald/__main__.py b/hub/herald/__main__.py index 835820b..3532469 100644 --- a/hub/herald/__main__.py +++ b/hub/herald/__main__.py @@ -9,13 +9,13 @@ from hub.herald.service import HubServerService def main(): parser = argparse.ArgumentParser( - prog='scribe-hub' + prog='herald' ) ServerEnv.contribute_to_arg_parser(parser) args = parser.parse_args() try: env = ServerEnv.from_arg_parser(args) - setup_logging(os.path.join(env.db_dir, 'scribe-hub.log')) + setup_logging(os.path.join(env.db_dir, 'herald.log')) server = HubServerService(env) server.run() except Exception: diff --git a/scripts/deploy_scribe_dev.sh b/scripts/deploy_scribe_dev.sh index e22c196..c84297e 100755 --- a/scripts/deploy_scribe_dev.sh +++ b/scripts/deploy_scribe_dev.sh @@ -7,7 +7,7 @@ SCRIPTS_DIR=`dirname $0` SCRIBE_DIR=`dirname $SCRIPTS_DIR` # build the image -docker build -f $SCRIBE_DIR/docker/Dockerfile -t lbry/scribe:development $SCRIBE_DIR +docker build -f $SCRIBE_DIR/Dockerfile -t lbry/scribe:development $SCRIBE_DIR IMAGE=`docker image inspect lbry/scribe:development | sed -n "s/^.*Id\":\s*\"sha256:\s*\(\S*\)\".*$/\1/p"` # push the image to the server diff --git a/docker/scribe_entrypoint.sh b/scripts/entrypoint.sh similarity index 52% rename from docker/scribe_entrypoint.sh rename to scripts/entrypoint.sh index 2f44c48..e78adec 100755 --- a/docker/scribe_entrypoint.sh +++ b/scripts/entrypoint.sh @@ -5,13 +5,13 @@ set -euo pipefail if [ -z "$HUB_COMMAND" ]; then - echo "HUB_COMMAND env variable must be scribe, scribe-hub, or scribe-elastic-sync" + echo "HUB_COMMAND env variable must be scribe, herald, or scribe-elastic-sync" exit 1 fi case "$HUB_COMMAND" in scribe ) exec /home/lbry/.local/bin/scribe "$@" ;; - scribe-hub ) exec /home/lbry/.local/bin/scribe-hub "$@" ;; + scribe-hub ) exec /home/lbry/.local/bin/herald "$@" ;; scribe-elastic-sync ) exec /home/lbry/.local/bin/scribe-elastic-sync "$@" ;; - * ) "HUB_COMMAND env variable must be scribe, scribe-hub, or scribe-elastic-sync" && exit 1 ;; + * ) "HUB_COMMAND env variable must be scribe, herald, or scribe-elastic-sync" && exit 1 ;; esac diff --git a/docker/set_build.py b/scripts/set_build.py similarity index 100% rename from docker/set_build.py rename to scripts/set_build.py diff --git a/setup.py b/setup.py index f065699..41ea264 100644 --- a/setup.py +++ b/setup.py @@ -23,9 +23,9 @@ setup( zip_safe=False, entry_points={ 'console_scripts': [ - 'scribe=scribe.blockchain.__main__:main', - 'scribe-hub=scribe.hub.__main__:main', - 'scribe-elastic-sync=scribe.elasticsearch.__main__:main', + 'scribe=hub.scribe.__main__:main', + 'herald=hub.herald.__main__:main', + 'scribe-elastic-sync=hub.elastic_sync.__main__:main', ], }, install_requires=[