fix(docker): Update Dockerfile to install ca-certificates and create unprivileged user
fix(settings): Ensure SSL_CERT_FILE is set using certifi if not already defined chore(requirements): Add certifi to requirements for SSL certificate handling
This commit is contained in:
parent
69ef3ccf72
commit
4c78500ec9
@ -10,7 +10,11 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
|||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
|
|
||||||
# Create an unprivileged user to run the app
|
# Create an unprivileged user to run the app
|
||||||
RUN adduser --disabled-password --gecos '' app
|
RUN set -ex && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y --no-install-recommends ca-certificates && \
|
||||||
|
rm -rf /var/lib/apt/lists/* && \
|
||||||
|
adduser --disabled-password --gecos '' app
|
||||||
|
|
||||||
COPY requirements.txt /tmp/requirements.txt
|
COPY requirements.txt /tmp/requirements.txt
|
||||||
RUN set -ex && \
|
RUN set -ex && \
|
||||||
|
|||||||
@ -13,9 +13,18 @@ https://docs.djangoproject.com/en/5.2/ref/settings/
|
|||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
try:
|
||||||
|
import certifi
|
||||||
|
except Exception:
|
||||||
|
certifi = None
|
||||||
|
|
||||||
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
BASE_DIR = os.path.dirname(PROJECT_DIR)
|
BASE_DIR = os.path.dirname(PROJECT_DIR)
|
||||||
|
|
||||||
|
# Ensure Python SSL always has a CA bundle unless caller explicitly sets one.
|
||||||
|
if not os.environ.get("SSL_CERT_FILE") and certifi is not None:
|
||||||
|
os.environ["SSL_CERT_FILE"] = certifi.where()
|
||||||
|
|
||||||
def env_list(name, default):
|
def env_list(name, default):
|
||||||
"""
|
"""
|
||||||
Return a list from a comma-separated env var; fall back to provided default list.
|
Return a list from a comma-separated env var; fall back to provided default list.
|
||||||
|
|||||||
@ -4,4 +4,5 @@ gunicorn
|
|||||||
dj-database-url
|
dj-database-url
|
||||||
psycopg[binary]
|
psycopg[binary]
|
||||||
python-dotenv
|
python-dotenv
|
||||||
django-storages[boto3]
|
django-storages[boto3]
|
||||||
|
certifi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user