See https://stackoverflow.com/a/
24540011/171898 and
https://docs.docker.com/engine/reference/builder/#usage
The directory passed to docker is the context. Previously we changed
directory into `ci/$IMAGE` then passed `.` as the "context".
Passing a subdir as context prevents any inclusion of files outside the
context, which isn't what we want: we want to include `requirements.txt`
from the root.
So instead, pass the entire repo as "context", and use the "-f" flag to
set the Dockerfile used.
Should help with #1743 and !1784
<<: *docker_definition
stage: build_docker_images
script:
- - cd ci/$IMAGE
# fetches the :latest image (not failing if image is not found) for caching
- docker pull $CI_REGISTRY_IMAGE/$IMAGE:latest || true
# Build and push with git commit SHA tag, reusing layers from the :latest image if possible
- - docker build -t $CI_REGISTRY_IMAGE/$IMAGE:$CI_COMMIT_SHA --cache-from $CI_REGISTRY_IMAGE/$IMAGE:latest .
+ - docker build -t $CI_REGISTRY_IMAGE/$IMAGE:$CI_COMMIT_SHA --cache-from $CI_REGISTRY_IMAGE/$IMAGE:latest -f ci/$IMAGE/Dockerfile .
- docker push $CI_REGISTRY_IMAGE/$IMAGE:$CI_COMMIT_SHA
.docker_push_template: &docker_push_definition