From 089a60fd7682f67376b140b914f8c4261294e9b0 Mon Sep 17 00:00:00 2001 From: Noah Kantrowitz Date: Thu, 26 Sep 2019 12:07:58 -0700 Subject: [PATCH] Improvements for Dockerfile. Installs from the local code rather than a release version, creates a non-root user, and switches from entrypoint to cmd for better customization. --- Dockerfile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7848eaa520..790364eb0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ -FROM python:3.6.6-alpine3.8 as builder +FROM python:3.6-alpine as builder RUN apk --no-cache add g++ zeromq-dev -RUN pip install locustio pyzmq +COPY . /src +WORKDIR /src +RUN pip install . -FROM python:3.6.6-alpine3.8 +FROM python:3.6-alpine -RUN apk --no-cache add zeromq-dev +RUN apk --no-cache add zeromq && adduser -h / -s /bin/false -H -D locust COPY --from=builder /usr/local/lib/python3.6/site-packages /usr/local/lib/python3.6/site-packages COPY --from=builder /usr/local/bin/locust /usr/local/bin/locust COPY docker_start.sh docker_start.sh @@ -13,4 +15,5 @@ RUN chmod +x docker_start.sh EXPOSE 8089 5557 5558 -ENTRYPOINT ["./docker_start.sh"] +USER locust +CMD ["./docker_start.sh"]