From d093915678716c1b0a1c36bff0e308ec02e98daf Mon Sep 17 00:00:00 2001 From: Daniel Font Date: Wed, 20 Sep 2023 07:33:25 +0200 Subject: [PATCH 1/2] [OPT-928] Refactor Dockerfile.application to use multistage approach. --- deployment/Dockerfile.application | 20 +++++++++++++++---- .../Quickstart-Guide-for-Integrations.md | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/deployment/Dockerfile.application b/deployment/Dockerfile.application index f581ebf7..f5a8476e 100644 --- a/deployment/Dockerfile.application +++ b/deployment/Dockerfile.application @@ -1,4 +1,4 @@ -FROM python:3.8-alpine +FROM python:3.8-alpine as builder WORKDIR /usr/src/app @@ -15,9 +15,21 @@ COPY . . RUN pip install . -RUN rm -r ../app/* -# Remove not needed dependencies for runtime -RUN apk del git geos-dev re2-dev py3-pybind11-dev +FROM python:3.8-alpine + +WORKDIR /app + +RUN apk update && \ + apk add libmagic && \ + apk add re2 && \ + apk add graphviz && \ + apk add lapack && \ + apk add cblas && \ + apk add geos \ + +COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages + +COPY --from=builder /usr/local/bin/startleft /usr/local/bin/startleft CMD ["startleft", "server", "--host", "0.0.0.0"] diff --git a/docs/integration/Quickstart-Guide-for-Integrations.md b/docs/integration/Quickstart-Guide-for-Integrations.md index cb6d9789..3b354899 100644 --- a/docs/integration/Quickstart-Guide-for-Integrations.md +++ b/docs/integration/Quickstart-Guide-for-Integrations.md @@ -59,7 +59,7 @@ git checkout release/1.5.0 Now, we can create the StartLeft image: ```shell -docker build . -f deployment/Dockerfile.docs.application.application -t startleft +docker build . -f deployment/Dockerfile.application -t startleft ``` And, finally, we can run the docker container for the image we have just generated. Notice that you can select the From 757e0f815cd8c2dfa664526ea6e9da2af500927d Mon Sep 17 00:00:00 2001 From: Santi Manero Date: Wed, 20 Sep 2023 11:44:55 +0200 Subject: [PATCH 2/2] [OPT-928] fixed a little syntax issue and renamed build stage --- deployment/Dockerfile.application | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deployment/Dockerfile.application b/deployment/Dockerfile.application index f5a8476e..2bb190a1 100644 --- a/deployment/Dockerfile.application +++ b/deployment/Dockerfile.application @@ -1,4 +1,4 @@ -FROM python:3.8-alpine as builder +FROM python:3.8-alpine AS startleft-base WORKDIR /usr/src/app @@ -26,10 +26,10 @@ RUN apk update && \ apk add graphviz && \ apk add lapack && \ apk add cblas && \ - apk add geos \ + apk add geos -COPY --from=builder /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages +COPY --from=startleft-base /usr/local/lib/python3.8/site-packages /usr/local/lib/python3.8/site-packages -COPY --from=builder /usr/local/bin/startleft /usr/local/bin/startleft +COPY --from=startleft-base /usr/local/bin/startleft /usr/local/bin/startleft CMD ["startleft", "server", "--host", "0.0.0.0"]