Skip to content

Commit 8c753d7

Browse files
c-wauvipy
authored andcommitted
Enable docker mounting of test directory (celery#4692)
This is achieved by cleaning up pyc files in the docker entrypoint script which avoids mismatches between compiled Python files on the docker host and/or from previous build steps by construction: before executing any command in the docker container, any remnant platform specific files are cleaned up and as such any subsequent py.test command will run in a clean environment.
1 parent c04effc commit 8c753d7

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

docker/Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ COPY --chown=1000:1000 celery $HOME/celery
7070

7171
RUN pyenv exec pip install -e .
7272

73-
# the compiled files from earlier steps will cause py.test to fail with
74-
# an ImportMismatchError
75-
RUN make clean-pyc
76-
77-
# Setup the entrypoint, this ensures pyenv is initialized when a container is started.
73+
# Setup the entrypoint, this ensures pyenv is initialized when a container is started
74+
# and that any compiled files from earlier steps or from moutns are removed to avoid
75+
# py.test failing with an ImportMismatchError
7876
ENTRYPOINT ["/entrypoint"]

docker/docker-compose.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ services:
1616
WORKER_LOGLEVEL: DEBUG
1717
tty: true
1818
volumes:
19+
- ../docs:/home/developer/docs
1920
- ../celery:/home/developer/celery
20-
# Because pytest fails when it encounters files from alternative python compilations,
21-
# __pycache__ and pyc files, PYTHONDONTWRITEBYTECODE must be
22-
# set on the host as well or py.test will throw configuration errors.
23-
# - ../t:/home/$CELERY_USER/t
21+
- ../t:/home/developer/t
2422
depends_on:
2523
- rabbit
2624
- redis

docker/entrypoint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
2+
3+
make --quiet --directory="$HOME" clean-pyc
4+
25
eval "$(pyenv init -)"
36
eval "$(pyenv virtualenv-init -)"
47
exec "$@"

0 commit comments

Comments
 (0)