forked from celery/celery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker-compose and base dockerfile for development (celery#4482)
* Add docker-compose and base dockerfile for development * Change to base jessie docker image and setup pyenv * Add in aliases for pyenv, fix entrypoint for docker * Update dockerfile to be non-root and fix encoding problems with tox * Add convenience method to get redis connection for tests * Add pypy to install commands * Force worker to pick up broker url from environment * Move pypy comment to above apt-get install, default python to 3.6, add in flag to prevent bytecode * Add documentation * Fix links * Update docs * Add to contributors * Address feedback: improve documentation, separate dockerfile into scripts, remove redundancy in pyenv setup, add in .env file * Setup pyenv environments correctly in dockerfile * Update capitalization * Change CELERY_USER to ARG in dockerfile and pass build argument in build * Change default worker loglevel to debug in docker-compose
- Loading branch information
1 parent
9ac3e37
commit 59d1400
Showing
14 changed files
with
206 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CELERY_USER=developer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
FROM debian:jessie | ||
|
||
ENV PYTHONIOENCODING UTF-8 | ||
|
||
# Pypy is installed from a package manager because it takes so long to build. | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
curl \ | ||
git \ | ||
libbz2-dev \ | ||
libcurl4-openssl-dev \ | ||
libmemcached-dev \ | ||
libncurses5-dev \ | ||
libreadline-dev \ | ||
libsqlite3-dev \ | ||
libssl-dev \ | ||
pkg-config \ | ||
pypy \ | ||
wget \ | ||
zlib1g-dev | ||
|
||
# Setup variables. Even though changing these may cause unnecessary invalidation of | ||
# unrelated elements, grouping them together makes the Dockerfile read better. | ||
ENV PROVISIONING /provisioning | ||
|
||
# This is provisioned from .env | ||
ARG CELERY_USER=developer | ||
|
||
# Check for mandatory build arguments | ||
RUN : "${CELERY_USER:?CELERY_USER build argument needs to be set and non-empty.}" | ||
|
||
ENV HOME /home/$CELERY_USER | ||
ENV PATH="$HOME/.pyenv/bin:$PATH" | ||
|
||
# Copy and run setup scripts | ||
WORKDIR $PROVISIONING | ||
COPY docker/scripts/install-couchbase.sh . | ||
# Scripts will lose thier executable flags on copy. To avoid the extra instructions | ||
# we call the shell directly. | ||
RUN sh install-couchbase.sh | ||
COPY docker/scripts/create-linux-user.sh . | ||
RUN sh create-linux-user.sh | ||
|
||
# Swap to the celery user so packages and celery are not installed as root. | ||
USER $CELERY_USER | ||
|
||
COPY docker/scripts/install-pyenv.sh . | ||
RUN sh install-pyenv.sh | ||
|
||
# Install celery | ||
WORKDIR $HOME | ||
COPY --chown=1000:1000 requirements $HOME/requirements | ||
COPY --chown=1000:1000 docker/entrypoint /entrypoint | ||
RUN chmod gu+x /entrypoint | ||
|
||
# Define the local pyenvs | ||
RUN pyenv local python2.7 python3.4 python3.5 python3.6 | ||
|
||
# Setup one celery environment for basic development use | ||
RUN pyenv exec pip install \ | ||
-r requirements/default.txt \ | ||
-r requirements/pkgutils.txt \ | ||
-r requirements/test.txt \ | ||
-r requirements/test-ci-base.txt \ | ||
-r requirements/test-integration.txt | ||
|
||
COPY --chown=1000:1000 MANIFEST.in Makefile setup.py setup.cfg tox.ini $HOME/ | ||
COPY --chown=1000:1000 t $HOME/t | ||
COPY --chown=1000:1000 celery $HOME/celery | ||
|
||
RUN pyenv exec pip install -e . | ||
|
||
# the compiled files from earlier steps will cause py.test to fail with | ||
# an ImportMismatchError | ||
RUN make clean-pyc | ||
|
||
# Setup the entrypoint, this ensures pyenv is initialized when a container is started. | ||
ENTRYPOINT ["/entrypoint"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: '2' | ||
|
||
services: | ||
celery: | ||
build: | ||
context: .. | ||
dockerfile: docker/Dockerfile | ||
args: | ||
CELERY_USER: | ||
environment: | ||
TEST_BROKER: pyamqp://rabbit:5672 | ||
TEST_BACKEND: redis://redis | ||
PYTHONUNBUFFERED: 1 | ||
PYTHONDONTWRITEBYTECODE: 1 | ||
REDIS_HOST: redis | ||
WORKER_LOGLEVEL: DEBUG | ||
tty: true | ||
volumes: | ||
- ../celery:/home/$CELERY_USER/celery | ||
# Because pytest fails when it encounters files from alternative python compilations, | ||
# __pycache__ and pyc files, PYTHONDONTWRITEBYTECODE must be | ||
# set on the host as well or py.test will throw configuration errors. | ||
# - ../t:/home/$CELERY_USER/t | ||
depends_on: | ||
- rabbit | ||
- redis | ||
- dynamodb | ||
|
||
rabbit: | ||
image: rabbitmq:3.7.3 | ||
|
||
redis: | ||
image: redis:3.2.11 | ||
|
||
dynamodb: | ||
image: dwmkerr/dynamodb:38 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
eval "$(pyenv init -)" | ||
eval "$(pyenv virtualenv-init -)" | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
addgroup --gid 1000 $CELERY_USER | ||
adduser --system --disabled-password --uid 1000 --gid 1000 $CELERY_USER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
wget http://packages.couchbase.com/clients/c/libcouchbase-2.8.4_jessie_amd64.tar | ||
tar -vxf libcouchbase-2.8.4_jessie_amd64.tar | ||
dpkg -i libcouchbase-2.8.4_jessie_amd64/libcouchbase2-core_2.8.4-1_amd64.deb | ||
dpkg -i libcouchbase-2.8.4_jessie_amd64/libcouchbase-dev_2.8.4-1_amd64.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
# For managing all the local python installations for testing, use pyenv | ||
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash | ||
|
||
# To enable testing versions like 3.4.8 as 3.4 in tox, we need to alias | ||
# pyenv python versions | ||
git clone https://github.com/s1341/pyenv-alias.git $(pyenv root)/plugins/pyenv-alias | ||
|
||
# Python versions to test against | ||
VERSION_ALIAS="python2.7" pyenv install 2.7.14 | ||
VERSION_ALIAS="python3.4" pyenv install 3.4.8 | ||
VERSION_ALIAS="python3.5" pyenv install 3.5.5 | ||
VERSION_ALIAS="python3.6" pyenv install 3.6.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters