Harden runtime configuration and container security defaults
This commit is contained in:
13
Dockerfile
13
Dockerfile
@ -24,7 +24,10 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PIP_NO_CACHE_DIR=1 \
|
||||
VIRTUAL_ENV=/opt/venv \
|
||||
PATH="/opt/venv/bin:${PATH}"
|
||||
PATH="/opt/venv/bin:/home/app/.local/bin:${PATH}" \
|
||||
APP_USER=app \
|
||||
APP_UID=10001 \
|
||||
APP_GID=10001
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@ -32,6 +35,10 @@ RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends libpq5 postgresql-client curl nodejs npm \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN groupadd --gid "${APP_GID}" "${APP_USER}" \
|
||||
&& useradd --uid "${APP_UID}" --gid "${APP_GID}" --create-home --shell /usr/sbin/nologin "${APP_USER}"
|
||||
RUN printf '%s\n' 'export PATH="/opt/venv/bin:/home/app/.local/bin:$PATH"' > /etc/profile.d/hoopscout-path.sh
|
||||
|
||||
COPY --from=builder /opt/venv /opt/venv
|
||||
COPY . /app
|
||||
|
||||
@ -39,7 +46,9 @@ RUN if [ -f package.json ]; then npm install --no-audit --no-fund; fi
|
||||
RUN if [ -f package.json ]; then npm run build; fi
|
||||
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
RUN mkdir -p /app/staticfiles /app/media /app/runtime
|
||||
RUN mkdir -p /app/staticfiles /app/media /app/runtime /app/node_modules /app/static/vendor \
|
||||
&& chown -R "${APP_UID}:${APP_GID}" /app /opt/venv
|
||||
|
||||
USER ${APP_UID}:${APP_GID}
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
CMD ["gunicorn", "config.wsgi:application", "--bind", "0.0.0.0:8000"]
|
||||
|
||||
Reference in New Issue
Block a user