Skip to content

Add Docker for easy usage#329

Merged
thinkingserious merged 16 commits into
sendgrid:masterfrom
gabrielkrell:master
Aug 10, 2017
Merged

Add Docker for easy usage#329
thinkingserious merged 16 commits into
sendgrid:masterfrom
gabrielkrell:master

Conversation

@gabrielkrell

@gabrielkrell gabrielkrell commented Aug 6, 2017

Copy link
Copy Markdown
Contributor

Add a Docker container to make it easier to try out or contribute to sendgrid-python.

  • Add Dockerfile, startup shell script, readme
  • Update+improve tox.ini
  • Prism install bugfix

Note: Don't approve until sendgrid/python Docker Hub has been created + linked. Also, should probably be squashed based on # of tiny commits.

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Aug 6, 2017
@gabrielkrell gabrielkrell changed the title Add Docker option Add Docker for easy usage Aug 6, 2017
Remove Python 3.2, 3.3.  Load dependencies from requirements.txt.
Wait until we download and install Prism to start running it.
Nothing says your virtualenv is under venv/ or that you're using one at all.
Everything but python 2.6 uses unittest discover, so might as well make it easy to change.
See gabrielkrell/sendgrid-python-docker for commit history.

Dockerfile downloads python versions, Prism, tox, default (latest at build time) SendGrid libs.  Maintains symlinks for easy use.
Add SendGrid footer, headers.  Clean up examples, add actual code.
Be more clear about how to use old versions.
@gabrielkrell
gabrielkrell force-pushed the master branch 2 times, most recently from 568cca7 to cc7ab1b Compare August 7, 2017 01:59
Graphical tweaks, mostly.  Single space after sentences.
@gabrielkrell
gabrielkrell force-pushed the master branch 14 times, most recently from 89e97cc to 605d27d Compare August 8, 2017 18:59
Turns out GitHub's syntax highlighting for bash sessions sucks, though.  They pull from a documented repo, so one to-do is contribute to this in personal time.

@thinkingserious thinkingserious 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.

Nice work!

Comment thread docker/Dockerfile Outdated
@@ -0,0 +1,42 @@
FROM ubuntu:latest

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.

Maybe we should pin this to a particular version so that we have a specific working configuration.

@gabrielkrell gabrielkrell Aug 8, 2017

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.

ubuntu:latest points to the latest LTS release (16.04 right now). I wanted to avoid forgetting about it later on and having an old version, but I guess it's worth the trouble to avoid a possible break when we're not expecting it.

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.

Added (in 31fea3a).

Comment thread docker/Dockerfile
RUN ln -s /root/sources/sendgrid-python/sendgrid && \
ln -s /root/sources/python-http-client/python_http_client

COPY entrypoint.sh entrypoint.sh

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.

This looks like it's copying to the same directory.

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.

Using COPY as an alternative to ADD; apparently it's best-practice. It copies entrypoint.sh from the directory the Dockerfile is in into /root (set with WORKDIR earlier) and runs from there later on. The final directory structure looks like this:

/root
  entrypoint.sh
  sendgrid
  python_http_client
  /sources
    /python-http-client
      README.md
      /python_http_client
      ...
    /sendgrid-python
      README.md
      /sendgrid
      ...

Comment thread docker/README.md Outdated
- `sendgrid-python` and `python-http-client`
- Stoplight's Prism, which lets you try out the API without actually sending email
- A complete setup for testing the repository or your own fork

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.

We should mention the various version of Python that are installed.

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.

It's a little unwieldy to mention the specific versions (especially as this can change); I'll mention details of the setup here and save individual versions for running the container.

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.

Added (in 31fea3a).

Comment thread docker/README.md Outdated
$ docker run -it sendgrid/sendgrid-python:v3.6.1
```

Tags from before this Docker image was created might not exist yet. You may [manually download](#Versions) old versions in order to use them.

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.

We should link them to the release tags: https://github.com/sendgrid/sendgrid-python/releases

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.

Added (in 31fea3a).

Comment thread docker/entrypoint.sh Outdated
fi

SENDGRID_PYTHON_VERSION=$(python2.7 -c 'import sendgrid; print(sendgrid.__version__)')
echo "Welcome to the sendgrid-python docker (version $SENDGRID_PYTHON_VERSION)"

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.

You can remove "the" here.

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.

Added (in 31fea3a).

Comment thread docker/entrypoint.sh Outdated

if [ "$1" != "--no-mock" ]
then
echo "Starting Prism in mock mode. Disable this by running this container with --no-mock."

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.

We don't say what mock mode means.

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.

Ah, I see you reference it as passthrough mode later. We should be consistent and say mock/no-mock or something similar.

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.

Added (in 31fea3a).

Comment thread docker/entrypoint.sh Outdated
echo "To stop Prism, run \"kill $!\" from the shell."

echo
echo "Starting python. Type \"import sendgrid\" to get started; return to shell with exit()."

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.

Python should be capitalized here.

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.

Added (in 31fea3a).

Dockerfile
 - Pin to specific Ubuntu
Readme:
 - Mention preinstalled Pythons
 - Link to releases page
Entrypoint:
 - Tidy welcome text
 - Explain mock/no-mock mode
 - Remove "passthrough"
 - Tidy exit text
@gabrielkrell

gabrielkrell commented Aug 9, 2017

Copy link
Copy Markdown
Contributor Author

Thanks Elmer! I'll ping you once the Docker Hub thing is set up and this is ready to go.

New README.md because it shows up in Docker Hub.  Moved old contents to USAGE.md.
Consistency with other readmes
Linking to the Docker Hub page for now, even though USAGE.md is better.
@gabrielkrell
gabrielkrell force-pushed the master branch 3 times, most recently from 46e4d55 to 4b557ca Compare August 10, 2017 02:37
Add docker hype to readme preheader, "dev env" section of contributing.
@thinkingserious
thinkingserious merged commit 9bc8c9c into sendgrid:master Aug 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: code review request requesting a community code review or review from Twilio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants