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

Dockerize python-threatexchange #1291

Merged
merged 1 commit into from
Mar 28, 2023
Merged

Conversation

dougneal
Copy link
Contributor

@dougneal dougneal commented Mar 28, 2023

Summary

Reduce user friction by providing a Docker container for the CLI. This eliminates the need for the user to have to care about Python.

To make for a clean Docker image layout, the persistent state directory is now configurable. While the default remains ~/.threatexchange, it can now be overridden by setting a TX_STATEDIR environment variable.

Test Plan

$ docker build --tag threatexchange .
$ docker run threatexchange --help
usage: threatexchange [-h] [--factory-reset] [--version] [--verbose]
                      {config,fetch,match,label,dataset,hash} ...

Wrapper for the `threatexchange` library, can serve as a simple e2e solution.
...

@github-actions github-actions bot added the python-threatexchange Items related to the threatexchange python tool / library label Mar 28, 2023
@dougneal dougneal changed the title Set up Dockerfile for python-threatexchange Dockerize python-threatexchange Mar 28, 2023
@dougneal dougneal marked this pull request as ready for review March 28, 2023 18:27
@dougneal dougneal requested a review from Dcallies as a code owner March 28, 2023 18:27
Copy link
Contributor

@BarrettOlson BarrettOlson left a comment

Choose a reason for hiding this comment

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

Awesome! here on in another PR I think it is worth updated the README.md with details/expected usage

@dougneal
Copy link
Contributor Author

The README changes got stuck on my machine. Fixed

@dougneal dougneal marked this pull request as draft March 28, 2023 19:06
@BarrettOlson BarrettOlson self-requested a review March 28, 2023 19:10
@dougneal dougneal marked this pull request as ready for review March 28, 2023 19:12
Copy link
Contributor

@Dcallies Dcallies left a comment

Choose a reason for hiding this comment

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

I don't use a lot of docker - what does this allow that users might like?

@dougneal
Copy link
Contributor Author

I don't use a lot of docker - what does this allow that users might like?

The value to the user is that they don't have to be Python developers to run it, or even care about their Python install at all. Just docker build followed by docker run and you have a functional CLI. The value will be even greater when you can spin up the API in the same manner.

If we were to publish the Docker image to the Docker hub or another container registry, they wouldn't even need the build step, just docker run docker.example.com/threatexchange.

Copy link
Contributor

@Dcallies Dcallies left a comment

Choose a reason for hiding this comment

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

So close! Just need to run black!

* Define a basic Docker container based on the official Python container
* Enable persistent config and state with a Docker volume
* Make the state dir configurable via environment variable `TX_STATEDIR`
@dougneal dougneal merged commit 991ef58 into facebook:main Mar 28, 2023
6 checks passed
@dougneal dougneal deleted the dockerize-pytx branch March 28, 2023 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed python-threatexchange Items related to the threatexchange python tool / library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants