Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'docker-compose' file #1163

Merged
merged 25 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4a27ebd
Add a simple 'docker-compose' file to run the server in a single step…
toddgardner Apr 5, 2024
b7d5afa
Update docker-compose.yml
toddgardner Apr 6, 2024
8b38684
Add the options file to docker compose
toddgardner Apr 6, 2024
0c85efc
Add docker compose networking & environment opts
chaoticbear Mar 18, 2024
b6e6dca
Add shared external docker network
chaoticbear Mar 18, 2024
93b4d00
Standardize service & container names
chaoticbear Mar 18, 2024
d1897fd
Adjust docker network config
chaoticbear Mar 18, 2024
a1fe738
Add Docker dev steps to README
chaoticbear Mar 18, 2024
5324b1c
Remove unnecessary Dockerfile
chaoticbear Apr 6, 2024
866679b
Add env var overrides to docker compose config
chaoticbear Apr 6, 2024
1e52558
Move sample.env - .docker & adjust gitignore
chaoticbear Apr 6, 2024
8565afb
Add db image override option
chaoticbear Apr 6, 2024
0e4a95a
Consolidate DC instructions, add env var info
chaoticbear Apr 6, 2024
c8bb71e
Remove extra imsd sample conf
chaoticbear Apr 6, 2024
4f10ba4
Fix db image syntax
chaoticbear Apr 6, 2024
c7b6c35
Match db password from sample conf
chaoticbear Apr 6, 2024
9462586
Add MARIADB_USER to set username
chaoticbear Apr 6, 2024
4a5fc13
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 6, 2024
59de52b
Fix overlines
toddgardner Apr 6, 2024
649af9a
Add items to manifest, remove test code
toddgardner Apr 7, 2024
1b8a9ef
Adjust manifest
toddgardner Apr 7, 2024
212593a
Adjust MANIFEST to make lint pass
toddgardner Apr 7, 2024
1787049
Merge branch 'master' into todd/docker-compose
wsanchez Apr 22, 2024
8c62207
Update MANIFEST.in with sdist in mind.
wsanchez Apr 23, 2024
ee4c415
Merge branch 'master' into todd/docker-compose
wsanchez Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +12 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What reads these *.env files? docker-compose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, docker-compose reads them in and uses them to populate vars in the file, some of which are passed through to the services.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are starting MySQL up we probably should also use that for the directory, but it would be a pain to set up from scratch.

We need a pair of dump files to add in this process: one for a starting directory and another for a IMS DB with something to fiddle with.

I guess that could be a follow-on PR; no need to block here.


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:
toddgardner marked this conversation as resolved.
Show resolved Hide resolved
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}"
Loading