@@ -4,9 +4,10 @@ ENV PYTHONUNBUFFERED 1
44ENV DEBIAN_FRONTEND noninteractive
55ENV LANG C.UTF-8
66ENV COLLECTSTATIC 1
7- ARG NODE_ENV=production
7+
88RUN useradd -ms /bin/bash django
99RUN mkdir -p /app
10+ RUN chown django:django /app
1011
1112RUN apt-get -qq update && apt-get install -qq -y \
1213 gconf-service \
@@ -62,27 +63,29 @@ ENTRYPOINT ["entrypoint.sh"]
6263
6364FROM base as dev
6465
66+ ARG NODE_ENV=production
67+ ARG REQUIREMENTS=requirements.txt
68+
6569RUN apt-get -qq update && apt-get install -qq -y \
6670 build-essential \
6771 python3.8-dev python3.8-venv python3.8-distutils && \
6872 apt-get clean all && rm -rf /var/apt/lists/* && rm -rf /var/cache/apt/*
6973
7074# install pip & requirements
7175RUN wget https://bootstrap.pypa.io/get-pip.py && python3.8 get-pip.py && rm get-pip.py
76+
77+ USER django
7278RUN python3.8 -m venv /app/venv
7379RUN /app/venv/bin/pip3 install --no-cache-dir pip setuptools wheel -U
7480
75- COPY requirements.txt /requirements.txt
76- RUN /app/venv/bin/pip3 install --no-cache-dir -r /requirements.txt -U
81+ COPY ${REQUIREMENTS} /app /requirements.txt
82+ RUN /app/venv/bin/pip3 install --no-cache-dir -r /app/ requirements.txt -U && rm /app/requirements.txt
7783RUN /app/venv/bin/nodeenv /app/venv/ -C '' -p -n 14.15.5
7884
7985# upgrade npm & requirements
8086COPY package.json /app/package.json
8187COPY package-lock.json /app/package-lock.json
82- RUN . /app/venv/bin/activate && npm ci
83- RUN mkdir -p /app/static
84- RUN chown django:django -R /app
85- USER django
88+ RUN . /app/venv/bin/activate && npm ci && rm /app/*.json
8689
8790CMD ["./manage.py" , "runserver" , "0.0.0.0:8000" ]
8891
@@ -93,7 +96,6 @@ COPY --from=dev /app/node_modules /app/node_modules
9396COPY src /app/src
9497
9598RUN mkdir -p /app/static
96- RUN chown django:django /app/static
9799
98100VOLUME /app/static
99101
0 commit comments