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

Move deployment to dokku #385

Merged
merged 17 commits into from
Jan 5, 2024
Merged

Move deployment to dokku #385

merged 17 commits into from
Jan 5, 2024

Conversation

rebkwok
Copy link
Contributor

@rebkwok rebkwok commented Jan 4, 2024

Moves deployment of BennettBot to a dokku app on dokku3.

In the process, I've removed the webserver /callback endpoint, and the code in dispatcher.py that builds it. As far as i can tell, this wasn't being used by anything. In the past it was used by cohort-extractor, back when the slack bot was used to run cohort-extractor commands - 22fba6e. No jobs in job_configs.py use the EBMBOT_CALLBACK_URL.

I also added a couple of extra settings, most notably the FAB_WORKSPACE_DIR, which means that fabric jobs, which fetch a fabfile from a remote repo and create a workspace dir to put it in, can write those files to a directory in the mounted storage volume, which the non-root docker user has access to.

Currently this is deployed on dokku3 using the the test BennettBot and workspace (bennetttest.slack.com) and commands are working (including op ones). Once merged, it needs the following environment variables updated to the real BennettBot:

  • SLACK_BOT_TOKEN
  • SLACK_APP_TOKEN
  • SLACK_SIGNING_SECRE
  • SLACK_APP_USERNAME

OpenPrescribing will also need its webhook payload URL updated https://github.com/ebmdatalab/openprescribing/settings/hooks/85994427

Still to do (in a later PR):

  • upgrade to fabric - fabric3 is deprecated and no longer maintained. Fabric now supports python3, so we should move to using the main fabric package. However, this involves updating the fabfiles on OpenPrescribing and the clinical trials tracker repos first.
  • upgrade python - we're stuck on python 3.9 because of fabric3

When we've upgrade fabric3 to standard fabric on OP and fdaaa, we
can do the same here. Until then we're stuck at 3.9
I am fairly confident that the only thing that used this callback
url was a very old edition of cohort-extractor
22fba6e
…b can live elsewhere

This means that the non-root docker user doesn't need write access to
files that exist only in the container.
Copy link
Contributor

@inglesp inglesp left a comment

Choose a reason for hiding this comment

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

Looks really good, thanks for doing this.

#
# Not including the code at this stage has two benefits:
#
# 1) this image only rebuilds when the handlful of files needed to build output-explorer-base
Copy link
Contributor

Choose a reason for hiding this comment

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

s/output-explorer-base/bennettbot-base/

DEPLOY.md Outdated

ebmbot is deployed on smallweb1 and is managed by systemd.
Deployment uses `dokku` and requires the environment variables defined in `dotenv-sample`.
Copy link
Contributor

Choose a reason for hiding this comment

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

This implies (to me) that it reads the environment variables from dotenv-sample, but I don't think that's the case. Can you clarify?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this is a leftover from when I thought I was going to put dummy env vars in dotenv-sample, but eventually didn't. It's only there for local development now

DEPLOY.md Outdated

ebmbot is deployed on smallweb1 and is managed by systemd.
Deployment uses `dokku` and requires the environment variables defined in `dotenv-sample`.
It is deployed to our `dokku3` instance.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd mention at the top that it's deployed automatically.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree this is safe to remove. Had completely forgotten we supported generating cohorts via Slack!

@@ -162,7 +163,7 @@ def notify_end(self, rc):
else:
return
else:
msg = f"Command `{self.job['type']}` failed (find logs in {self.log_dir}). Calling tech-support."
msg = f"Command `{self.job['type']}` failed (find logs in {self.host_log_dir}). Calling tech-support."
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we say "find logs in ... on dokku3"?

@rebkwok rebkwok merged commit c03eb9e into main Jan 5, 2024
6 checks passed
@rebkwok rebkwok deleted the dokku branch January 5, 2024 17:18
@rebkwok rebkwok mentioned this pull request Jan 10, 2024
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.

2 participants