Skip to content

Commit

Permalink
Merge pull request #1163 from toddgardner/todd/docker-compose
Browse files Browse the repository at this point in the history
Add  'docker-compose' file
  • Loading branch information
wsanchez authored Apr 23, 2024
2 parents 7472322 + ee4c415 commit 6f11f13
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .docker/sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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
# IMS_DB_ROOT_PASSWORD=%
# IMS_DB_ROOT_PASSWORD=ims-root
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.docker
/.hypothesis
/.tox
/build/
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
/htmldocs/
/src/*.egg-info/
__pycache__/
*.env
/.docker/*
!/.docker/sample.env
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include .codecov.yml
include .coveragerc
include .docker/sample.env
include .dockerignore
include .flake8
include .isort.cfg
Expand All @@ -15,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
Expand Down
26 changes: 26 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ 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/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

------------------
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/
Expand All @@ -58,6 +78,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``.
Expand All @@ -66,6 +91,7 @@ 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.


Pull Requests
~~~~~~~~~~~~~

Expand Down
56 changes: 56 additions & 0 deletions conf/imsd-docker-compose-sample.conf
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
services:
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_PASSWORD: "${IMS_DB_PASSWORD:-ims}"
volumes:
- ./conf:/opt/ims/conf
- ./:/srv/ims
ports:
- ${IMS_SERVER_PORT:-8080}:8080
depends_on:
database:
condition: service_healthy
command:
- /opt/ims/bin/ims
- "--log-file"
- "-"
- "--config"
- "/opt/ims/conf/imsd.conf"
- server

database:
image: "${IMS_DB_IMAGE:-mariadb:10.5.24}"
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}"
volumes:
- ./.docker/mysql/data/:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 5

networks:
default:
name: "${DOCKER_RANGERS_NETWORK:-rangers}"

0 comments on commit 6f11f13

Please sign in to comment.