Skip to content

Commit 5ef0d24

Browse files
refactor: Use multistage Docker build to include only built libraries in Docker image (#717)
* Use a Docker multistage build to copy over only the built Python libraries to the final image * Use 'docker images' to show built image size at end of CI build
1 parent f2646f3 commit 5ef0d24

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,5 @@ jobs:
126126
- uses: actions/checkout@v1.2.0
127127
- name: Build Docker image
128128
run: |
129-
docker build . --file docker/Dockerfile --tag pyhf:$GITHUB_SHA
129+
docker build . --file docker/Dockerfile --tag pyhf/pyhf:$GITHUB_SHA
130+
docker images

docker/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
FROM matthewfeickert/python3-scipy-alpine:scipy-1.2.1
1+
FROM matthewfeickert/python3-scipy-alpine:scipy-1.2.1 as base
2+
3+
FROM base as builder
24
COPY . /code
35
RUN cd /code && \
46
apk add --no-cache git && \
57
rm -rf /var/cache/apk/* && \
68
python -m pip install --upgrade --no-cache-dir pip setuptools wheel && \
7-
python -m pip install --no-cache-dir -e .[xmlio] && \
9+
python -m pip install --no-cache-dir .[xmlio] && \
810
python -m pip list
11+
12+
FROM base
13+
COPY --from=builder /usr/local /usr/local
914
ENTRYPOINT ["/usr/local/bin/pyhf"]

0 commit comments

Comments
 (0)