Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use non-root user #68

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:jammy-20240808
FROM ubuntu:jammy

LABEL name="httpbin"
LABEL description="A simple HTTP service."
Expand All @@ -9,11 +9,30 @@ ENV HOME=/httpbin

WORKDIR /httpbin

RUN apt update -y && apt install python3-pip libssl-dev libffi-dev git -y && pip3 install --no-cache-dir pipenv
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
httpbin

RUN chown httpbin /httpbin
RUN chmod u+rwx /httpbin

RUN apt-get update -y && apt-get install python3-pip libssl-dev libffi-dev git libcap2-bin -y

ADD . .
RUN pipenv sync

RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/python3.10
EXPOSE 80

USER httpbin
ENV PATH="/httpbin/.local/bin:$PATH"

RUN pip3 install --no-cache-dir pipenv
RUN pipenv sync

CMD ["pipenv", "run", "gunicorn", "-b", "0.0.0.0:80", "httpbin:app", "-k", "gevent"]
Loading