Skip to content

Commit

Permalink
Prune Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Dec 19, 2023
1 parent bd6dd22 commit c983c09
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions netkan/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
FROM python:3.11 as base
FROM ubuntu:latest as ubuntu_with_python

# Don't prompt for time zone
ENV DEBIAN_FRONTEND=noninteractive

# Install Git and Python
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git libffi-dev openssh-client \
python3 python-is-python3 \
&& apt-get clean

FROM ubuntu_with_python as base
RUN apt-get install -y --no-install-recommends \
python3-pip python3-setuptools python3-dev
RUN useradd -ms /bin/bash netkan
ADD . /netkan
WORKDIR /netkan
Expand All @@ -7,8 +21,8 @@ RUN chown -R netkan:netkan /netkan
USER netkan
RUN pip install --user . --no-warn-script-location

FROM python:3.11 as production
COPY --from=base /home/netkan /home/netkan
FROM ubuntu_with_python as production
COPY --from=base /home/netkan/.local /home/netkan/.local
RUN useradd -Ms /bin/bash netkan
RUN chown -R netkan:netkan /home/netkan
WORKDIR /home/netkan
Expand All @@ -21,6 +35,8 @@ CMD ["--help"]

FROM production as test
USER root
RUN apt-get install -y --no-install-recommends \
python3-pip python3-setuptools python3-dev
RUN pip install pip --upgrade
ADD . /netkan
RUN chown -R netkan:netkan /netkan
Expand All @@ -31,6 +47,8 @@ RUN /home/netkan/.local/bin/pytest -v

FROM production as dev
USER root
RUN apt-get install -y --no-install-recommends \
python3-pip python3-setuptools python3-dev
RUN pip install pip --upgrade
ADD . /netkan
RUN chown -R netkan:netkan /netkan
Expand Down

0 comments on commit c983c09

Please sign in to comment.