Skip to content

Instantly share code, notes, and snippets.

@Lauriy
Last active July 30, 2024 11:29
Show Gist options
  • Save Lauriy/22b305a925d8a21bf496c87b0419de1b to your computer and use it in GitHub Desktop.
Save Lauriy/22b305a925d8a21bf496c87b0419de1b to your computer and use it in GitHub Desktop.
Dockerfile stage that installs uWSGI and sets non-root permissions
FROM base AS production
# Let's allow .pycs again
ENV PYTHONDONTWRITEBYTECODE=0
# Needed to compile uwsgi, clean up after
RUN --mount=type=cache,target=/var/cache/apt apt-get update && apt-get install -y --no-install-recommends \
build-essential \
python3-dev \
libpcre3-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,target=/root/.cache/pip pip --no-cache-dir install uwsgi
COPY uwsgi.ini ./
# Best practice not to give pwners free root
RUN useradd -m docker
RUN mkdir -p /home/docker/rik_proovitöö/run /home/docker/rik_proovitöö/static_collected
RUN chown -R docker:docker /home/docker/rik_proovitöö
RUN chmod 755 /home/docker/rik_proovitöö/run
USER docker
COPY rik_proovitöö ./rik_proovitöö
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment