From 4a27ebdf5799c60ff7872a3b81bee7765843673c Mon Sep 17 00:00:00 2001 From: Todd Gardner Date: Thu, 4 Apr 2024 23:22:24 -0400 Subject: [PATCH 01/23] Add a simple 'docker-compose' file to run the server in a single step wtih 'docker-compose up' --- .dockerignore | 1 + .gitignore | 1 + README.rst | 15 +++++++++++++++ docker-compose.yml | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore index 4b6cf2f88..9415b08cc 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ +/.docker /.hypothesis /.tox /build/ diff --git a/.gitignore b/.gitignore index bf788de6b..efe5b582d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.docker_environment /.hypothesis /.tox +/.docker /build/ /cached/ /data/ diff --git a/README.rst b/README.rst index a79d3a5f6..b762357ea 100644 --- a/README.rst +++ b/README.rst @@ -41,6 +41,21 @@ To run all of the default test environments:: Running the Server ~~~~~~~~~~~~~~~~~~ +------------------ + With docker-compose +------------------ + +Run:: + + # First time setup; these files are mounted into the container + cp conf/directory-sample.yaml conf/directory.yaml + + docker-compose up + +------------------ + Outside docker +------------------ + To run the server will require some configuration, and if you try to start the server with the default configuration, you will probably see an error such as this:: 2020-03-12T09:16:55-0700 [ims.run._command.Command#info] Setting up web service at http://localhost:80/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..d2af6be33 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,37 @@ +version: "3.8" + +services: + server: + build: . + environment: + IMS_DIRECTORY: File + IMS_DIRECTORY_FILE: /opt/ims/conf/directory.yaml + IMS_DB_HOST_NAME: mysql + IMS_DB_DATABASE: ims + IMS_DB_USER_NAME: ims + IMS_DB_PASSWORD: ims + volumes: + - ./conf:/opt/ims/conf + - ./:/srv/ims + ports: + - "8080:80" + depends_on: + mysql: + condition: service_healthy + links: + - mysql + mysql: + image: mariadb:10.5.17 + environment: + MARIADB_DATABASE: ims + MARIADB_USER: ims + MARIADB_PASSWORD: ims + MARIADB_ROOT_HOST: "%" + MARIADB_ROOT_PASSWORD: ims-root + volumes: + - ./.docker/mysql/data/:/var/lib/mysql + healthcheck: + test: ["CMD", "mysqladmin", "ping", "--password=ims-root"] + interval: 10s + timeout: 5s + retries: 5 From b7d5afa8383794a60297be177cf469db04610432 Mon Sep 17 00:00:00 2001 From: Todd Gardner Date: Fri, 5 Apr 2024 21:52:45 -0400 Subject: [PATCH 02/23] Update docker-compose.yml Co-authored-by: Bear --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index d2af6be33..735c82178 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: "3.8" services: server: build: . + user: :${DAEMON_GROUP_ID:-1420} environment: IMS_DIRECTORY: File IMS_DIRECTORY_FILE: /opt/ims/conf/directory.yaml From 8b386846472580f561547279a06b35c7e416c7ab Mon Sep 17 00:00:00 2001 From: Todd Gardner Date: Fri, 5 Apr 2024 23:15:09 -0400 Subject: [PATCH 03/23] Add the options file to docker compose --- README.rst | 8 +++- conf/imsd-docker-compose-sample.conf | 56 ++++++++++++++++++++++++++++ docker-compose.yml | 18 +++++---- 3 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 conf/imsd-docker-compose-sample.conf diff --git a/README.rst b/README.rst index b762357ea..56f1c6d90 100644 --- a/README.rst +++ b/README.rst @@ -48,9 +48,10 @@ Running the Server Run:: # First time setup; these files are mounted into the container + cp conf/imsd-docker-compose-sample.conf conf/imsd.conf cp conf/directory-sample.yaml conf/directory.yaml - docker-compose up + docker compose up ------------------ Outside docker @@ -73,6 +74,11 @@ To build and run the server (for development only):: tox run -e exec + +------------------ + Settings Permissions +------------------ + In your browser, open http://localhost:8080/ to reach the server. Log in as any user in the ``conf/directory.yaml`` directory file. In the ``conf/imsd.conf`` sample configuration file, the users ``Hardware`` and ``Loosy`` are administrators, and in the sample directory, all users have passwords that match their handles. You'll want to log in as one of those to set up an Event. Use the pull-down menu at the top right corner of the page (it will show the logged in user's Ranger handle), and select ``Admin``. On the next page, navigate to the Events page and create an event called ``Test``. diff --git a/conf/imsd-docker-compose-sample.conf b/conf/imsd-docker-compose-sample.conf new file mode 100644 index 000000000..dd3abc004 --- /dev/null +++ b/conf/imsd-docker-compose-sample.conf @@ -0,0 +1,56 @@ +[Core] + +# Absolute or relative to parent of parent of this file +ServerRoot = . + +DataStore = MySQL +Directory = File + +# Absolute or relative to ServerRoot +ConfigRoot = conf +DataRoot = data +CachedResources = cache + +# Bind address +Host = localhost +Port = 8080 + +Admins = Hardware, Loosy + +#MasterKey = 6C21E8C9-8B83-4EA3-93BD-6C6EFE8A712B + +#JWTSecret = DD264110-3A97-4348-9473-6D50B582550C + +RequireActive = True + + +[Store:SQLite] + +# Relative to DataRoot +File = db.sqlite + + +[Store:MySQL] + +HostName = mysql +HostPort = 3306 + +Database = ims +UserName = ims +Password = ims + + +[Directory:File] + +# Relative to ConfigRoot +File = directory.yaml + + +[Directory:ClubhouseDB] + +Hostname = dms.rangers.example.com +HostPort = 3306 + +Database = rangers +Username = ims +Password = 9F29BB2B-E775-489C-9C20-9FE3EFEE1F22 diff --git a/docker-compose.yml b/docker-compose.yml index 735c82178..9e6c671b9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,23 +6,25 @@ services: user: :${DAEMON_GROUP_ID:-1420} environment: IMS_DIRECTORY: File - IMS_DIRECTORY_FILE: /opt/ims/conf/directory.yaml - IMS_DB_HOST_NAME: mysql - IMS_DB_DATABASE: ims - IMS_DB_USER_NAME: ims - IMS_DB_PASSWORD: ims volumes: - ./conf:/opt/ims/conf - ./:/srv/ims ports: - - "8080:80" + - "8080:8080" depends_on: mysql: condition: service_healthy links: - mysql + command: + - /opt/ims/bin/ims + - "--log-file" + - "-" + - "--config" + - "/opt/ims/conf/imsd.conf" + - server mysql: - image: mariadb:10.5.17 + image: mariadb:10.5.24 environment: MARIADB_DATABASE: ims MARIADB_USER: ims @@ -32,7 +34,7 @@ services: volumes: - ./.docker/mysql/data/:/var/lib/mysql healthcheck: - test: ["CMD", "mysqladmin", "ping", "--password=ims-root"] + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] interval: 10s timeout: 5s retries: 5 From 0c85efc024fc60af3a29fcbcf142b3e96e1dc7a8 Mon Sep 17 00:00:00 2001 From: wood ape Date: Sun, 17 Mar 2024 17:32:55 -0700 Subject: [PATCH 04/23] Add docker compose networking & environment opts Support faster development environment provisioning with a docker & docker-compose setup. --- .gitignore | 1 + conf/imsd-sample-docker.conf | 56 ++++++++++++++++++++++++++++++++++++ dev.Dockerfile | 21 ++++++++++++++ docker-compose.yml | 6 ++-- sample.env | 2 ++ 5 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 conf/imsd-sample-docker.conf create mode 100644 dev.Dockerfile create mode 100644 sample.env diff --git a/.gitignore b/.gitignore index efe5b582d..51b56597e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /htmldocs/ /src/*.egg-info/ __pycache__/ +.sample.env \ No newline at end of file diff --git a/conf/imsd-sample-docker.conf b/conf/imsd-sample-docker.conf new file mode 100644 index 000000000..55723fca8 --- /dev/null +++ b/conf/imsd-sample-docker.conf @@ -0,0 +1,56 @@ +[Core] + +# Absolute or relative to parent of parent of this file +ServerRoot = . + +DataStore = SQLite +Directory = File + +# Absolute or relative to ServerRoot +ConfigRoot = conf +DataRoot = data +CachedResources = cache + +# Bind address +Host = 0.0.0.0 +Port = 8080 + +Admins = Hardware, Loosy + +#MasterKey = 6C21E8C9-8B83-4EA3-93BD-6C6EFE8A712B + +#JWTSecret = DD264110-3A97-4348-9473-6D50B582550C + +RequireActive = True + + +[Store:SQLite] + +# Relative to DataRoot +File = db.sqlite + + +[Store:MySQL] + +HostName = localhost +HostPort = 3306 + +Database = ims +UserName = ims +Password = 7B33108D-4CD4-41B5-A244-B16F97038860 + + +[Directory:File] + +# Relative to ConfigRoot +File = directory.yaml + + +[Directory:ClubhouseDB] + +Hostname = dms.rangers.example.com +HostPort = 3306 + +Database = rangers +Username = ims +Password = 9F29BB2B-E775-489C-9C20-9FE3EFEE1F22 diff --git a/dev.Dockerfile b/dev.Dockerfile new file mode 100644 index 000000000..bc673e72b --- /dev/null +++ b/dev.Dockerfile @@ -0,0 +1,21 @@ +# ----------------------------------------------------------------------------- +# This stage builds the development container. +# ----------------------------------------------------------------------------- +FROM python:3.12.1-alpine3.18 as development + +# Paths +ARG IMS_SERVER_ROOT="/srv/ims" + +# Install libraries. +RUN apk add --no-cache libressl +RUN pip install --upgrade setuptools +RUN pip install --upgrade tox +RUN rm -rf /root/.cache + +# Allow Python to bind to privileged port numbers +RUN apk add --no-cache libcap +RUN setcap "cap_net_bind_service=+ep" /usr/local/bin/python3.12 + +# Set user and default working directory +USER daemon:daemon +WORKDIR "${IMS_SERVER_ROOT}" diff --git a/docker-compose.yml b/docker-compose.yml index 9e6c671b9..476bc7f7e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.8" - services: server: build: . @@ -10,7 +8,7 @@ services: - ./conf:/opt/ims/conf - ./:/srv/ims ports: - - "8080:8080" + - ${IMS_SERVER_PORT:-8080}:8080 depends_on: mysql: condition: service_healthy @@ -37,4 +35,4 @@ services: test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] interval: 10s timeout: 5s - retries: 5 + retries: 5 \ No newline at end of file diff --git a/sample.env b/sample.env new file mode 100644 index 000000000..ae5351c0c --- /dev/null +++ b/sample.env @@ -0,0 +1,2 @@ +DAEMON_GROUP_ID=1420 # Match your docker group ID for permissions +IMS_SERVER_PORT=8080 \ No newline at end of file From b6e6dcafd465b813b9bfc44acd6f919b3d7cbd63 Mon Sep 17 00:00:00 2001 From: wood ape Date: Sun, 17 Mar 2024 18:34:59 -0700 Subject: [PATCH 05/23] Add shared external docker network Supports external ranger-ims-web FE project with access to the backend API. --- docker-compose.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 476bc7f7e..3605edb93 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,4 +35,9 @@ services: test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] interval: 10s timeout: 5s - retries: 5 \ No newline at end of file + retries: 5 + +networks: + default: + external: true + name: "${DOCKER_RANGERS_NETWORK:-rangers}" From 93b4d00443469b04914c61c582987b4c1f6e04f9 Mon Sep 17 00:00:00 2001 From: wood ape Date: Sun, 17 Mar 2024 18:38:07 -0700 Subject: [PATCH 06/23] Standardize service & container names --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3605edb93..10d75a3a2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ services: - server: + app: build: . + container_name: ranger_ims_server user: :${DAEMON_GROUP_ID:-1420} environment: IMS_DIRECTORY: File @@ -21,6 +22,7 @@ services: - "--config" - "/opt/ims/conf/imsd.conf" - server + mysql: image: mariadb:10.5.24 environment: From d1897fd95cef7ee3ddede0853af4170754c620be Mon Sep 17 00:00:00 2001 From: wood ape Date: Sun, 17 Mar 2024 19:36:03 -0700 Subject: [PATCH 07/23] Adjust docker network config --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 10d75a3a2..fa142f681 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,5 +41,4 @@ services: networks: default: - external: true name: "${DOCKER_RANGERS_NETWORK:-rangers}" From a1fe7382bb084ffaac69363b293d0de16361a966 Mon Sep 17 00:00:00 2001 From: wood ape Date: Sun, 17 Mar 2024 19:36:23 -0700 Subject: [PATCH 08/23] Add Docker dev steps to README --- README.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.rst b/README.rst index 56f1c6d90..1fd69611d 100644 --- a/README.rst +++ b/README.rst @@ -87,6 +87,17 @@ In the box labeled ``Access for Test (writers)``, enter the string ``*``. That You should now be able to select your new event from the ``Event`` menu at the top right, and then create new incidents within that event. +Development with docker +~~~~~~~~~~~~~~~~~~~~~~~ + +Build the Docker Image: + + docker compose build app + +Run the App + + docker compose up app -d + Pull Requests ~~~~~~~~~~~~~ From 5324b1cc2b1fc8b56ec0a81f8f5b098f36de0af5 Mon Sep 17 00:00:00 2001 From: wood ape Date: Fri, 5 Apr 2024 20:40:15 -0700 Subject: [PATCH 09/23] Remove unnecessary Dockerfile --- dev.Dockerfile | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 dev.Dockerfile diff --git a/dev.Dockerfile b/dev.Dockerfile deleted file mode 100644 index bc673e72b..000000000 --- a/dev.Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -# ----------------------------------------------------------------------------- -# This stage builds the development container. -# ----------------------------------------------------------------------------- -FROM python:3.12.1-alpine3.18 as development - -# Paths -ARG IMS_SERVER_ROOT="/srv/ims" - -# Install libraries. -RUN apk add --no-cache libressl -RUN pip install --upgrade setuptools -RUN pip install --upgrade tox -RUN rm -rf /root/.cache - -# Allow Python to bind to privileged port numbers -RUN apk add --no-cache libcap -RUN setcap "cap_net_bind_service=+ep" /usr/local/bin/python3.12 - -# Set user and default working directory -USER daemon:daemon -WORKDIR "${IMS_SERVER_ROOT}" From 866679b37bd17d6c0afa1e6c1426f4b41fdebb60 Mon Sep 17 00:00:00 2001 From: wood ape Date: Fri, 5 Apr 2024 20:53:35 -0700 Subject: [PATCH 10/23] Add env var overrides to docker compose config --- docker-compose.yml | 21 +++++++++++++-------- sample.env | 10 ++++++++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index fa142f681..05f9383b0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,12 @@ services: container_name: ranger_ims_server user: :${DAEMON_GROUP_ID:-1420} environment: - IMS_DIRECTORY: File + IMS_DIRECTORY: "${IMS_DIRECTORY:-File}" + IMS_DIRECTORY_FILE: "${IMS_DIRECTORY_FILE:-/opt/ims/conf/directory.yaml}" + IMS_DB_HOST_NAME: "${IMS_DB_HOST_NAME:-ranger_ims_database}" + IMS_DB_DATABASE: "${IMS_DB_DATABASE:-ims}" + IMS_DB_USER_NAME: "${IMS_DB_USER_NAME:-ims}" + IMS_DB_PASSWORD: "${IMS_DB_PASSWORD:-7B33108D-4CD4-41B5-A244-B16F97038860}" volumes: - ./conf:/opt/ims/conf - ./:/srv/ims @@ -22,15 +27,15 @@ services: - "--config" - "/opt/ims/conf/imsd.conf" - server - - mysql: + + database: image: mariadb:10.5.24 + container_name: ranger_ims_database environment: - MARIADB_DATABASE: ims - MARIADB_USER: ims - MARIADB_PASSWORD: ims - MARIADB_ROOT_HOST: "%" - MARIADB_ROOT_PASSWORD: ims-root + MARIADB_DATABASE: "${IMS_DB_DATABASE:-ims}" + MARIADB_PASSWORD: "${IMS_DB_PASSWORD:-7B33108D-4CD4-41B5-A244-B16F97038860}" + MARIADB_ROOT_HOST: "${IMS_DB_ROOT_HOST:-%}" + MARIADB_ROOT_PASSWORD: "${IMS_DB_ROOT_PASSWORD:-ims-root}" volumes: - ./.docker/mysql/data/:/var/lib/mysql healthcheck: diff --git a/sample.env b/sample.env index ae5351c0c..88afd58a3 100644 --- a/sample.env +++ b/sample.env @@ -1,2 +1,8 @@ -DAEMON_GROUP_ID=1420 # Match your docker group ID for permissions -IMS_SERVER_PORT=8080 \ No newline at end of file +# DAEMON_GROUP_ID=1420 # Match your docker group ID for permissions +# IMS_SERVER_PORT=8080 +# DOCKER_RANGERS_NETWORK=rangers +# IMS_DB_HOST_NAME=ranger_ims_database +# IMS_DB_DATABASE=ims +# IMS_DB_PASSWORD=7B33108D-4CD4-41B5-A244-B16F97038860 +# IMS_DB_ROOT_PASSWORD=% +# IMS_DB_ROOT_PASSWORD=ims-root \ No newline at end of file From 1e525588da0645448cc7b2a2eabab61cb2abf179 Mon Sep 17 00:00:00 2001 From: wood ape Date: Fri, 5 Apr 2024 21:04:50 -0700 Subject: [PATCH 11/23] Move sample.env - .docker & adjust gitignore --- sample.env => .docker/sample.env | 0 .gitignore | 5 +++-- 2 files changed, 3 insertions(+), 2 deletions(-) rename sample.env => .docker/sample.env (100%) diff --git a/sample.env b/.docker/sample.env similarity index 100% rename from sample.env rename to .docker/sample.env diff --git a/.gitignore b/.gitignore index 51b56597e..42c519663 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ /.docker_environment /.hypothesis /.tox -/.docker /build/ /cached/ /data/ @@ -10,4 +9,6 @@ /htmldocs/ /src/*.egg-info/ __pycache__/ -.sample.env \ No newline at end of file +*.env +/.docker/* +!/.docker/sample.env \ No newline at end of file From 8565afbfbfd75dd7e3d24b198b97a4d4ed973073 Mon Sep 17 00:00:00 2001 From: wood ape Date: Fri, 5 Apr 2024 21:26:41 -0700 Subject: [PATCH 12/23] Add db image override option --- .docker/sample.env | 1 + docker-compose.yml | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.docker/sample.env b/.docker/sample.env index 88afd58a3..c61d16ad4 100644 --- a/.docker/sample.env +++ b/.docker/sample.env @@ -1,6 +1,7 @@ # DAEMON_GROUP_ID=1420 # Match your docker group ID for permissions # IMS_SERVER_PORT=8080 # DOCKER_RANGERS_NETWORK=rangers +# IMS_DB_IMAGE=mariadb:10.5.24 # IMS_DB_HOST_NAME=ranger_ims_database # IMS_DB_DATABASE=ims # IMS_DB_PASSWORD=7B33108D-4CD4-41B5-A244-B16F97038860 diff --git a/docker-compose.yml b/docker-compose.yml index 05f9383b0..44292cd21 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,10 +16,8 @@ services: ports: - ${IMS_SERVER_PORT:-8080}:8080 depends_on: - mysql: + database: condition: service_healthy - links: - - mysql command: - /opt/ims/bin/ims - "--log-file" @@ -29,7 +27,7 @@ services: - server database: - image: mariadb:10.5.24 + image: ${IMS_DB_IMAGE:-mariadb:10.5.24}" container_name: ranger_ims_database environment: MARIADB_DATABASE: "${IMS_DB_DATABASE:-ims}" From 0e4a95ace50830507790991c1e01a2c9d89adc6b Mon Sep 17 00:00:00 2001 From: wood ape Date: Fri, 5 Apr 2024 21:37:41 -0700 Subject: [PATCH 13/23] Consolidate DC instructions, add env var info --- README.rst | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index 1fd69611d..b5174ac47 100644 --- a/README.rst +++ b/README.rst @@ -51,6 +51,10 @@ Run:: cp conf/imsd-docker-compose-sample.conf conf/imsd.conf cp conf/directory-sample.yaml conf/directory.yaml + If you need to override any of the environment variables set in + `docker-compose.yml`, copy `.docker/sample.env` to `/.env` and + uncomment and edit the neccessary variables. + docker compose up ------------------ @@ -87,16 +91,6 @@ In the box labeled ``Access for Test (writers)``, enter the string ``*``. That You should now be able to select your new event from the ``Event`` menu at the top right, and then create new incidents within that event. -Development with docker -~~~~~~~~~~~~~~~~~~~~~~~ - -Build the Docker Image: - - docker compose build app - -Run the App - - docker compose up app -d Pull Requests ~~~~~~~~~~~~~ From c8bb71e753576f9838b431e98fd4d7c32d57ee7c Mon Sep 17 00:00:00 2001 From: wood ape Date: Fri, 5 Apr 2024 21:41:42 -0700 Subject: [PATCH 14/23] Remove extra imsd sample conf --- conf/imsd-sample-docker.conf | 56 ------------------------------------ 1 file changed, 56 deletions(-) delete mode 100644 conf/imsd-sample-docker.conf diff --git a/conf/imsd-sample-docker.conf b/conf/imsd-sample-docker.conf deleted file mode 100644 index 55723fca8..000000000 --- a/conf/imsd-sample-docker.conf +++ /dev/null @@ -1,56 +0,0 @@ -[Core] - -# Absolute or relative to parent of parent of this file -ServerRoot = . - -DataStore = SQLite -Directory = File - -# Absolute or relative to ServerRoot -ConfigRoot = conf -DataRoot = data -CachedResources = cache - -# Bind address -Host = 0.0.0.0 -Port = 8080 - -Admins = Hardware, Loosy - -#MasterKey = 6C21E8C9-8B83-4EA3-93BD-6C6EFE8A712B - -#JWTSecret = DD264110-3A97-4348-9473-6D50B582550C - -RequireActive = True - - -[Store:SQLite] - -# Relative to DataRoot -File = db.sqlite - - -[Store:MySQL] - -HostName = localhost -HostPort = 3306 - -Database = ims -UserName = ims -Password = 7B33108D-4CD4-41B5-A244-B16F97038860 - - -[Directory:File] - -# Relative to ConfigRoot -File = directory.yaml - - -[Directory:ClubhouseDB] - -Hostname = dms.rangers.example.com -HostPort = 3306 - -Database = rangers -Username = ims -Password = 9F29BB2B-E775-489C-9C20-9FE3EFEE1F22 From 4f10ba444ba262fa1c04607040a8582628697efa Mon Sep 17 00:00:00 2001 From: wood ape Date: Fri, 5 Apr 2024 21:59:02 -0700 Subject: [PATCH 15/23] Fix db image syntax --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 44292cd21..355700441 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: - server database: - image: ${IMS_DB_IMAGE:-mariadb:10.5.24}" + image: "${IMS_DB_IMAGE:-mariadb:10.5.24}" container_name: ranger_ims_database environment: MARIADB_DATABASE: "${IMS_DB_DATABASE:-ims}" From c7b6c351117a9225383f637d17d5ec81b7aac8ca Mon Sep 17 00:00:00 2001 From: wood ape Date: Fri, 5 Apr 2024 22:04:51 -0700 Subject: [PATCH 16/23] Match db password from sample conf --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 355700441..5a4c6bd47 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: IMS_DB_HOST_NAME: "${IMS_DB_HOST_NAME:-ranger_ims_database}" IMS_DB_DATABASE: "${IMS_DB_DATABASE:-ims}" IMS_DB_USER_NAME: "${IMS_DB_USER_NAME:-ims}" - IMS_DB_PASSWORD: "${IMS_DB_PASSWORD:-7B33108D-4CD4-41B5-A244-B16F97038860}" + IMS_DB_PASSWORD: "${IMS_DB_PASSWORD:-ims}" volumes: - ./conf:/opt/ims/conf - ./:/srv/ims @@ -31,7 +31,7 @@ services: container_name: ranger_ims_database environment: MARIADB_DATABASE: "${IMS_DB_DATABASE:-ims}" - MARIADB_PASSWORD: "${IMS_DB_PASSWORD:-7B33108D-4CD4-41B5-A244-B16F97038860}" + MARIADB_PASSWORD: "${IMS_DB_PASSWORD:-ims}" MARIADB_ROOT_HOST: "${IMS_DB_ROOT_HOST:-%}" MARIADB_ROOT_PASSWORD: "${IMS_DB_ROOT_PASSWORD:-ims-root}" volumes: From 9462586d65b72639a12f3d113677ae4bcdf53e87 Mon Sep 17 00:00:00 2001 From: wood ape Date: Fri, 5 Apr 2024 22:10:55 -0700 Subject: [PATCH 17/23] Add MARIADB_USER to set username --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index 5a4c6bd47..84ce00072 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,6 +31,7 @@ services: container_name: ranger_ims_database environment: MARIADB_DATABASE: "${IMS_DB_DATABASE:-ims}" + MARIADB_USER: "${IMS_DB_USER_NAME:-ims}" MARIADB_PASSWORD: "${IMS_DB_PASSWORD:-ims}" MARIADB_ROOT_HOST: "${IMS_DB_ROOT_HOST:-%}" MARIADB_ROOT_PASSWORD: "${IMS_DB_ROOT_PASSWORD:-ims-root}" From 4a5fc130006dabbccd204f2eb7e09831a0c150bd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 6 Apr 2024 07:55:19 +0000 Subject: [PATCH 18/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .docker/sample.env | 2 +- .gitignore | 2 +- README.rst | 4 ++-- docker-compose.yml | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.docker/sample.env b/.docker/sample.env index c61d16ad4..91b69260a 100644 --- a/.docker/sample.env +++ b/.docker/sample.env @@ -6,4 +6,4 @@ # IMS_DB_DATABASE=ims # IMS_DB_PASSWORD=7B33108D-4CD4-41B5-A244-B16F97038860 # IMS_DB_ROOT_PASSWORD=% -# IMS_DB_ROOT_PASSWORD=ims-root \ No newline at end of file +# IMS_DB_ROOT_PASSWORD=ims-root diff --git a/.gitignore b/.gitignore index 42c519663..f1fc5bf4b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,4 @@ __pycache__/ *.env /.docker/* -!/.docker/sample.env \ No newline at end of file +!/.docker/sample.env diff --git a/README.rst b/README.rst index b5174ac47..48e390422 100644 --- a/README.rst +++ b/README.rst @@ -51,8 +51,8 @@ Run:: cp conf/imsd-docker-compose-sample.conf conf/imsd.conf cp conf/directory-sample.yaml conf/directory.yaml - If you need to override any of the environment variables set in - `docker-compose.yml`, copy `.docker/sample.env` to `/.env` and + If you need to override any of the environment variables set in + `docker-compose.yml`, copy `.docker/sample.env` to `/.env` and uncomment and edit the neccessary variables. docker compose up diff --git a/docker-compose.yml b/docker-compose.yml index 84ce00072..2f8a041bd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,14 @@ services: - app: + app: build: . container_name: ranger_ims_server user: :${DAEMON_GROUP_ID:-1420} environment: IMS_DIRECTORY: "${IMS_DIRECTORY:-File}" IMS_DIRECTORY_FILE: "${IMS_DIRECTORY_FILE:-/opt/ims/conf/directory.yaml}" - IMS_DB_HOST_NAME: "${IMS_DB_HOST_NAME:-ranger_ims_database}" - IMS_DB_DATABASE: "${IMS_DB_DATABASE:-ims}" - IMS_DB_USER_NAME: "${IMS_DB_USER_NAME:-ims}" + IMS_DB_HOST_NAME: "${IMS_DB_HOST_NAME:-ranger_ims_database}" + IMS_DB_DATABASE: "${IMS_DB_DATABASE:-ims}" + IMS_DB_USER_NAME: "${IMS_DB_USER_NAME:-ims}" IMS_DB_PASSWORD: "${IMS_DB_PASSWORD:-ims}" volumes: - ./conf:/opt/ims/conf @@ -31,7 +31,7 @@ services: container_name: ranger_ims_database environment: MARIADB_DATABASE: "${IMS_DB_DATABASE:-ims}" - MARIADB_USER: "${IMS_DB_USER_NAME:-ims}" + MARIADB_USER: "${IMS_DB_USER_NAME:-ims}" MARIADB_PASSWORD: "${IMS_DB_PASSWORD:-ims}" MARIADB_ROOT_HOST: "${IMS_DB_ROOT_HOST:-%}" MARIADB_ROOT_PASSWORD: "${IMS_DB_ROOT_PASSWORD:-ims-root}" @@ -42,7 +42,7 @@ services: interval: 10s timeout: 5s retries: 5 - + networks: default: name: "${DOCKER_RANGERS_NETWORK:-rangers}" From 59de52b62f3c46e245c4673f912306d9f3a80a4d Mon Sep 17 00:00:00 2001 From: Todd Gardner Date: Sat, 6 Apr 2024 10:47:28 -0400 Subject: [PATCH 19/23] Fix overlines --- Dockerfile | 4 ++++ README.rst | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index fad135315..4fb4f053b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,6 +61,10 @@ RUN install -o daemon -g daemon -d "${IMS_SERVER_ROOT}" # Copy build result COPY --from=build "${IMS_INSTALL_DIR}" "${IMS_INSTALL_DIR}" +RUN python -m pip --no-cache-dir install pipx +RUN pipx install tox +#RUN tox deps + # Set user and default working directory USER daemon:daemon WORKDIR "${IMS_SERVER_ROOT}" diff --git a/README.rst b/README.rst index 48e390422..4c74fcb06 100644 --- a/README.rst +++ b/README.rst @@ -41,9 +41,9 @@ To run all of the default test environments:: Running the Server ~~~~~~~~~~~~~~~~~~ ------------------- - With docker-compose ------------------- +-------------------- +With docker-compose +-------------------- Run:: @@ -58,7 +58,7 @@ Run:: docker compose up ------------------ - Outside docker +Outside docker ------------------ To run the server will require some configuration, and if you try to start the server with the default configuration, you will probably see an error such as this:: @@ -79,9 +79,9 @@ To build and run the server (for development only):: tox run -e exec ------------------- - Settings Permissions ------------------- +--------------------- +Settings Permissions +--------------------- In your browser, open http://localhost:8080/ to reach the server. Log in as any user in the ``conf/directory.yaml`` directory file. In the ``conf/imsd.conf`` sample configuration file, the users ``Hardware`` and ``Loosy`` are administrators, and in the sample directory, all users have passwords that match their handles. You'll want to log in as one of those to set up an Event. From 649af9a358a14667ecba656a7f17e6b1a6ef199d Mon Sep 17 00:00:00 2001 From: Todd Gardner Date: Sun, 7 Apr 2024 10:13:10 -0400 Subject: [PATCH 20/23] Add items to manifest, remove test code --- Dockerfile | 4 ---- MANIFEST.in | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4fb4f053b..fad135315 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,10 +61,6 @@ RUN install -o daemon -g daemon -d "${IMS_SERVER_ROOT}" # Copy build result COPY --from=build "${IMS_INSTALL_DIR}" "${IMS_INSTALL_DIR}" -RUN python -m pip --no-cache-dir install pipx -RUN pipx install tox -#RUN tox deps - # Set user and default working directory USER daemon:daemon WORKDIR "${IMS_SERVER_ROOT}" diff --git a/MANIFEST.in b/MANIFEST.in index f0037cdc7..d558dd424 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ include .codecov.yml include .coveragerc include .dockerignore +include .docker/sample.env include .flake8 include .isort.cfg include .pre-commit-config.yaml @@ -17,6 +18,7 @@ include codecov.yml include conf/directory-sample.yaml include conf/imsd-sample.conf include COPYRIGHT.txt +include docker-compose.yml include Dockerfile include LICENSE.txt include mypy.ini @@ -24,6 +26,7 @@ include pyproject.toml include README.rst include requirements/requirements*.txt include tox.ini +recursive-include conf *.conf recursive-include docs *.py recursive-include docs *.rst recursive-include src *.txt From 1b8a9ef0ecf72893d7b1ed8fa0b30a205cfa1fa7 Mon Sep 17 00:00:00 2001 From: Todd Gardner Date: Sun, 7 Apr 2024 10:23:25 -0400 Subject: [PATCH 21/23] Adjust manifest --- MANIFEST.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index d558dd424..31173ed7e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,7 @@ +exclude docker-compose.yml include .codecov.yml include .coveragerc include .dockerignore -include .docker/sample.env include .flake8 include .isort.cfg include .pre-commit-config.yaml @@ -18,7 +18,6 @@ include codecov.yml include conf/directory-sample.yaml include conf/imsd-sample.conf include COPYRIGHT.txt -include docker-compose.yml include Dockerfile include LICENSE.txt include mypy.ini @@ -31,3 +30,4 @@ recursive-include docs *.py recursive-include docs *.rst recursive-include src *.txt recursive-include src/ims/element/static *.zip +recursive-exclude .docker From 212593acd28df7779cc58e6c9d46c9cd50cddf33 Mon Sep 17 00:00:00 2001 From: Todd Gardner Date: Sun, 7 Apr 2024 10:26:45 -0400 Subject: [PATCH 22/23] Adjust MANIFEST to make lint pass --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 31173ed7e..d9b6b8623 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -30,4 +30,4 @@ recursive-include docs *.py recursive-include docs *.rst recursive-include src *.txt recursive-include src/ims/element/static *.zip -recursive-exclude .docker +recursive-exclude .docker *.env From 8c62207975e0c620c629ebc37147188a8ccd1805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20S=C3=A1nchez=20Vega?= Date: Tue, 23 Apr 2024 13:34:08 -0700 Subject: [PATCH 23/23] Update MANIFEST.in with sdist in mind. --- MANIFEST.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index d9b6b8623..a1fe4acbb 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,6 @@ -exclude docker-compose.yml include .codecov.yml include .coveragerc +include .docker/sample.env include .dockerignore include .flake8 include .isort.cfg @@ -16,8 +16,10 @@ include bin/shell include bin/test_docker include codecov.yml include conf/directory-sample.yaml +include conf/imsd-docker-compose-sample.conf include conf/imsd-sample.conf include COPYRIGHT.txt +include docker-compose.yml include Dockerfile include LICENSE.txt include mypy.ini @@ -25,9 +27,7 @@ include pyproject.toml include README.rst include requirements/requirements*.txt include tox.ini -recursive-include conf *.conf recursive-include docs *.py recursive-include docs *.rst recursive-include src *.txt recursive-include src/ims/element/static *.zip -recursive-exclude .docker *.env