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

inv tasks to use when developing with docker #6418

Merged
merged 17 commits into from Dec 10, 2019
Merged

Conversation

@humitos
Copy link
Member

humitos commented Nov 28, 2019

This PR adds some invoke tasks to help developing with Docker and avoid writing a lot of docker-compose commands over and over again.

These tasks can be called like:

inv docker.up --no-search

inv docker.attach web

inv docker.restart proxito

inv docker.shell --container=proxito --running

inv docker.manage makemigrations

inv docker.manage shell_plus

inv docker.test --arguments='-e py36 -- -k "not automation_rule" --lf'

For example, restart helps us by restarting nginx automatically when it's needed.

Besides, this PR renames the docker/ directory to dockerfiles/ because we have installed a Python package named docker and it produces some conflicts. So, better to avoid this.

@humitos humitos requested a review from ericholscher Nov 28, 2019
These are some invoke tasks to help with developing with docker. Run
migrations from inside the container, attach to a running process,
launch a django shell in the web, etc.

`inv docker.up` to start all the containers

`inv docker.up --no-search` to start all the containers without search

`inv docker.manage shell_plus` to start a django shell inside the web
container

`inv docker.attach web` to attach the current shell to the web
process (useful to run pdb and debug)
@humitos humitos force-pushed the humitos/docker-tasks branch from 513708d to c7a81c7 Nov 28, 2019
@humitos humitos force-pushed the humitos/docker-tasks branch from 0fbfc21 to 5e5e229 Nov 28, 2019
humitos added 4 commits Nov 28, 2019
This is required to run the backend tests to avoid problems of
Unicode/Decode on branches with unicode names.
@humitos humitos force-pushed the humitos/docker-tasks branch from 6646262 to 760dea1 Nov 28, 2019
humitos added 2 commits Dec 1, 2019
When passing --init to "docker.up" we run specific commands that are
only needed the first time the containers are created (migrate, create
super user, collectstatic and loaddata)
@humitos

This comment has been minimized.

Copy link
Member Author

humitos commented Dec 1, 2019

I just added --init (default False) to the inv docker.up command so we can run the initial required commands the first time we create the all the containers/volumes (migrate, collectstatic, etc)

Copy link
Member

ericholscher left a comment

This makes sense to me, and will be much nicer. Just the INIT setup along is useful. I'd also like to figure out a way to have optional auto-reloading turned on, as it kills macos when enabled :)


../../docker/common.sh

if [ -n "$INIT" ];

This comment has been minimized.

Copy link
@ericholscher
@@ -24,7 +24,7 @@ class DockerBaseSettings(CommunityDevSettings):
MULTIPLE_BUILD_SERVERS = ['build']

# Enable auto syncing elasticsearch documents
ELASTICSEARCH_DSL_AUTOSYNC = True
ELASTICSEARCH_DSL_AUTOSYNC = True if 'SEARCH' in os.environ else False

This comment has been minimized.

Copy link
@ericholscher

ericholscher Dec 10, 2019

Member

This also is much nicer 👍

@ericholscher ericholscher merged commit c2609f5 into master Dec 10, 2019
3 checks passed
3 checks passed
continuous-documentation/read-the-docs Read the Docs build succeeded!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
pyup.io/safety-ci No dependencies with known security vulnerabilities.
Details
@ericholscher ericholscher deleted the humitos/docker-tasks branch Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.