FROM python:3.8.15-buster
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN mkdir -p /web/
WORKDIR /web/
COPY web deploy/entrypoint.sh requirements.txt ./
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
EXPOSE 8000
RUN adduser --disabled-password --gecos '' user && \
chown -R user:user /web && \
chmod -R 755 /web
USER user
CMD ./entrypoint.sh
FROM python:3.8.15-buster as dependency
COPY requirements.txt ./tmp
RUN pip install --upgrade pip && pip install --no-cache-dir -r /tmp/requirements.txt
FROM python:3.8.15-buster
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
EXPOSE 8000
COPY --from=dependency /usr/local/lib/python3.8/site-packages/ /usr/local/lib/python3.8/site-packages/
RUN mkdir -p /web/
WORKDIR /web/
COPY web deploy/entrypoint.sh ./
RUN adduser --disabled-password --gecos '' user && \
chown -R user:user /web && \
chmod -R 755 /web
USER user
CMD ./entrypoint.sh
이미지 크기에 차이가 없었다.
베이스 이미지가 원체 사이즈가 크다.(3.8.15-buster)
최종 이미지를 경량화하여 크기를 줄이면 되겠다.(slim 버전 적용)