Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Reorder Dockerfile commands to cache as many layers as possible

Patryk Zawadzkidae8e3817d57
diff --git a/Dockerfile b/Dockerfile
index bdab2d2319..6224b25913 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,9 +15,6 @@ RUN pip install -r requirements_dev.txt
### Final image
FROM python:3.8-slim
-ARG STATIC_URL
-ENV STATIC_URL ${STATIC_URL:-/static/}
-
RUN groupadd -r saleor && useradd -r -g saleor saleor
RUN apt-get update \
@@ -33,16 +30,18 @@ RUN apt-get update \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
-COPY . /app
+RUN mkdir -p /app/media /app/static \
+ && chown -R saleor:saleor /app/
+
COPY --from=build-python /usr/local/lib/python3.8/site-packages/ /usr/local/lib/python3.8/site-packages/
COPY --from=build-python /usr/local/bin/ /usr/local/bin/
+COPY . /app
WORKDIR /app
+ARG STATIC_URL
+ENV STATIC_URL ${STATIC_URL:-/static/}
RUN SECRET_KEY=dummy STATIC_URL=${STATIC_URL} python3 manage.py collectstatic --no-input
-RUN mkdir -p /app/media /app/static \
- && chown -R saleor:saleor /app/
-
EXPOSE 8000
ENV PORT 8000
ENV PYTHONUNBUFFERED 1