Copy source into image rather than mount in container

@acmiyaguchi reported that with the source mounted into the container,
cache files were written to the local file system that then
couldn't be removed without sudo on an Ubuntu host.

This change should make sure all cache files are written inside the
container so they don't hit the local filesystem.
This commit is contained in:
Jeff Klukas 2018-08-17 10:44:52 -04:00
Родитель 9bf1383ec4
Коммит 8acb376e37
3 изменённых файлов: 12 добавлений и 5 удалений

Просмотреть файл

@ -1,5 +1,5 @@
# Files/directories matching the patterns here will not be included
# in the Docker context when you run `docker build`.
# The tox caches can be large; we ignore them to speed up builds.
.*tox/
.*
*.egg*

Просмотреть файл

@ -7,3 +7,9 @@ FROM python:$PYTHON_VERSION
RUN apt-get update && apt-get install -y libsnappy-dev openjdk-8-jre-headless
RUN pip install tox
WORKDIR /python_moztelemetry
# Copy the current directory as is to the workdir;
# Relies on the .dockerignore file to prune out large files we don't want to include.
COPY . .

Просмотреть файл

@ -8,7 +8,7 @@ cd $(git rev-parse --show-toplevel)
# Set default variables if not already present in the environment.
: ${PYTHON_VERSION:=3.6}
: ${WORKDIR:=.dockertox} # Prevents the circleci cli from picking up the env
: ${TOXDIR:=.dockertox} # Prevents the circleci cli from picking up the env
: ${TOXENV:="py${PYTHON_VERSION/./}"}
# Set some derived variables.
@ -22,7 +22,8 @@ docker build -t moztelemetry:"$TOXENV" --build-arg PYTHON_VERSION="$PYTHON_VERSI
# We mount the current directory to the container and run tox inside it.
docker run -it --rm \
--volume "$(pwd)":/python_moztelemetry \
--volume "$(pwd)/$TOXDIR":/python_moztelemetry/"$TOXDIR" \
--volume "$(pwd)"/.git:/python_moztelemetry/.git \
--workdir /python_moztelemetry \
moztelemetry:"$TOXENV" \
tox --workdir $WORKDIR -e "$TOXENV" -- $@
tox --workdir "$TOXDIR" -e "$TOXENV" -- $@