Skip to content

Set up docker with dispatcherd for local development#18

Merged
abikouo merged 8 commits into
ansible:mainfrom
abikouo:dispatcherd_1
Aug 5, 2025
Merged

Set up docker with dispatcherd for local development#18
abikouo merged 8 commits into
ansible:mainfrom
abikouo:dispatcherd_1

Conversation

@abikouo

@abikouo abikouo commented Jul 4, 2025

Copy link
Copy Markdown
Contributor

Refer to AAP-47113

  • Add Docker compose configuration with PostgreSQL service, Worker service, and API/Ui service

Note: #25 has to be merged first

@abikouo abikouo force-pushed the dispatcherd_1 branch 7 times, most recently from 19a6fc5 to ad9b029 Compare July 9, 2025 09:00
@GomathiselviS

Copy link
Copy Markdown
Contributor

Hi @abikouo, I couldn't get the migrate command to work with manage.py inside src/pattern_service/. I tested moving manage.py to the src/ directory and adjusting its references, which fixed all the builds (docker build and docker compose) and migration.

Is there a step I'm overlooking, or should manage.py be located in the src/ directory?

@hakbailey hakbailey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In addition to the inline comments, I would suggest we remove the following from this PR:

  • Movement of code to the src directory. There are ongoing conversations org-wide about how we want to standardize platform service repository structure; let's hold off on making big changes in this regard until we know what those decisions are.
  • Dependency management with Poetry. This isn't standard for platform services either; let's stick with pyproject.toml for now.
  • Bash files to run tests and mypy, this shouldn't be necessary.
  • Addition of copyright statements to individual files. We may want to do this; however I would suggest we do it in a single PR to all existing files because adding it in this PR to only some files is introducing inconsistency across the repo. I would also like to verify what the org-wide guideline is for this.

Comment thread Makefile Outdated
Comment thread Makefile Outdated
Comment thread dispatcher_dev.yml Outdated
Comment thread dispatcher_dev.yml Outdated
Comment thread dispatcher_dev.yml Outdated
Comment thread src/pattern_service/core/tasks/worker.py Outdated
Comment thread src/pattern_service/core/utils/logging.py Outdated
Comment thread src/pattern_service/core/utils/logging.py Outdated
Comment thread src/pattern_service/core/views.py Outdated
Comment thread tools/docker/README.md Outdated
@@ -0,0 +1,51 @@
# Docker Compose for Development

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There is a push to move towards podman over docker within Red Hat generally; let's try to refer either to podman or just containers generally instead of specifying docker.

@abikouo

abikouo commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author

@hakbailey I have updated the PR based on what you did on #25. #25 has to be merged first.

Comment thread tools/docker/Dockerfile
Comment thread tools/docker/Dockerfile Outdated

ENV PATTERN_SERVICE_MODE=development

RUN python3.11 manage.py migrate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest you run the migration when the container starts because this adds a read-only layer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was able to create a read-write file for the db, what is the error on your side?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wasn't able to add anything else to the db because the migration was run in a read only layer. When creating a pattern I was getting something like "read-only database".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

django.db.utils.OperationalError: attempt to write a readonly database

@sonarqubecloud

sonarqubecloud Bot commented Jul 24, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@abikouo abikouo force-pushed the dispatcherd_1 branch 3 times, most recently from d3a5a50 to 4be3cad Compare July 29, 2025 11:41

@hakbailey hakbailey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It would be good to have the test endpoint submit a task to the dispatcher worker so we can verify this functionality; something simple like this would be fine.

I think it would also be valuable to update the logging section of the development settings to include dispatcherd DEBUG logs.

Comment thread .dockerignore Outdated
Comment thread Makefile Outdated
Comment thread Makefile Outdated
Comment thread tools/docker/docker-compose.yaml Outdated
Comment thread tools/docker/README.md Outdated
Comment thread pattern_service/settings/defaults.py Outdated
Comment thread pattern_service/settings/dispatcher.py Outdated
Comment thread pyproject.toml Outdated
@@ -0,0 +1,84 @@
x-environment: &common-env
PATTERN_SERVICE_DB_HOST: postgres

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are these env variables used for anything?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These environment variables will be part of the settings without the PATTERN_SERVICE prefix. They are used to configure the DB.

image: localhost/ansible-pattern-service-worker
environment:
<< : *common-env
PATTERN_SERVICE_DISPATCHER_NODE_ID: pattern-service-worker

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this env variable get used for anything?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the node ID that will be set in the dispatcher config.

Comment thread tools/podman/README.md Outdated
Comment thread tools/podman/README.md Outdated
Comment thread tools/podman/README.md Outdated
Comment thread pattern_service/settings/dispatcher.py Outdated
Comment thread Makefile Outdated

@hakbailey hakbailey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good and works as expected!

@beeankha beeankha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested locally, works as documented!

@abikouo abikouo merged commit 7dcc333 into ansible:main Aug 5, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants