Skip to content

Instantly share code, notes, and snippets.

@fsargent
Created May 1, 2024 22:13
Show Gist options
  • Save fsargent/4375eb4a99f4b902184a6a7412f72de7 to your computer and use it in GitHub Desktop.
Save fsargent/4375eb4a99f4b902184a6a7412f72de7 to your computer and use it in GitHub Desktop.
python3-saml segfault issues.

Dockerfile

FROM python:3.8-slim-bookworm as development
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# https://pythonspeed.com/articles/activate-virtualenv-dockerfile/
WORKDIR /app
ENV VIRTUAL_ENV=/opt/venv \
    POETRY_HOME=/opt/poetry \
    POETRY_VIRTUALENVS_IN_PROJECT=false \
    POETRY_VIRTUALENVS_CREATE=false \
    PATH="/opt/poetry/bin:/opt/venv:/bin:$PATH" \
    PYTHONFAULTHANDLER=1 \
    PYTHONUNBUFFERED=1 \
    PYTHONHASHSEED=random \
    PIP_NO_CACHE_DIR=off \
    PIP_DISABLE_PIP_VERSION_CHECK=on \
    PIP_DEFAULT_TIMEOUT=100 \
    DEBIAN_FRONTEND=noninteractive \
    DJANGO_SETTINGS_MODULE=mysite.settings

RUN apt-get update && \
    apt-get install -y -q \
    libpq-dev \
    libxml2-dev \
    libxmlsec1-dev \
    libxslt-dev \
    wkhtmltopdf \
    curl \
    build-essential \
    vim \
    htop \
    pkg-config \
    --no-install-recommends && \
    apt-get clean
RUN useradd -ms /bin/bash username
RUN chown -R username /opt /usr/local/ /app/
USER username
COPY ./poetry.lock ./poetry.toml ./pyproject.toml /app/
RUN curl -sSL https://install.python-poetry.org | python3.8 - --version 1.5.1 && \
    poetry install --no-interaction --no-ansi --no-cache

# Copy only essential files
COPY --chown=username:username ./ /app/
CMD ["./entrypoint.sh"]

poetry.toml

[installer]
no-binary = ["lxml", "xmlsec"]

Pyproject.toml

[tool.poetry]
name = "rbproj"
version = "0.1.1"
description = ""
authors = ["RecruitBot Inc"]
readme = "README.md"

[tool.poetry.dependencies]
backports-strenum = "^1.2.4"
boto3 = "^1.26.99"
certifi = "^2023.5.7"
debugpy = "^1.6.6"
demoji = "^1.1.0"
dj-snake = "^1.1.2"
django = "~4.2"
django-allauth = { extras = ["social-account"], version = "^0.62.1" }
django-cors-headers = "^3.13.0"
django-environ = "0.9.0"
django-extensions = "^3.2.0"
django-impersonate = "^1.8.2"
django-oauth-toolkit = "^2.3.0"
django-structlog = { extras = ["celery"], version = "^8.0.0" }
django-webserver = { extras = ["gunicorn"], version = "^1.2.0" }
django-widget-tweaks = "^1.4.12"
elasticsearch = "^6.1.1"
nh3 = "^0.2.13"
pdfkit = "^1.0.0"
pdfminer-six = "^20160614"
pkgconfig = "^1.4.0"
psycopg2-binary = "^2.9.5"
python = "~3.8"
python-dateutil = "^2.7.3"
python-dotenv = "^1.0.1"
python3-openid = "^3.1.0"
python3-saml = "^1.16.0"
pytz = "^2024.1"
requests = "^2.28.2"
requests-oauthlib = "^0.7.0"
rich = "^13.3.1"
s3transfer = "~0.6.0"
stripe = "^1.65.1"
supervisor = "^4.2.5"
typing-extensions = "^4.3.0"
underscore-py = "^0.1.6"
unidecode = "^0.4.20"
unittest-xml-reporting = "^3.2.0"
webencodings = "^0.5.1"
whitenoise = "^6.4.0"
honeycomb-opentelemetry = "^0.2.3b0"
opentelemetry-instrumentation-django = "^0.41b0"
opentelemetry-instrumentation-urllib3 = "^0.41b0"
opentelemetry-instrumentation-requests = "^0.41b0"
opentelemetry-instrumentation-elasticsearch = "^0.41b0"
openai = "1.8.0"
beautifulsoup4 = "^4.12.2"
devcycle-python-server-sdk = "^3.4.1"
sentry-sdk = { extras = ["django"], version = "^1.44.0" }
celery = { extras = ["redis"], version = "^5.3.6" }
redis = "^5.0.3"
structlog-sentry = "^2.1.0"
django-allow-cidr = "^0.7.1"
jwt = "^1.3.1"
xmlsec = "^1.3.14"
lxml = "5.2.1"

[tool.poetry.group.dev.dependencies]
black = "^24.3.0"
django-upgrade = "^1.13.0"
djlint = "^1.19.16"
httpretty = "^1.1.4"
model-bakery = "^1.10.1"
pylint-django = "^2.5.3"
pylint-junit = "^0.3.2"
pytest-cov = "^4.0.0"
pytest-django = "^4.5.2"
pytest-mock = "^3.10.0"
shiv = "^1.0.5"
django-types = "^0.19.1"
pyright = "^1.1.359"


# When adding here, also add to trunk.yaml
[tool.poetry.group.types.dependencies]
types-oauthlib = "^3.2.0.8"
types-pytz = "^2024.1.0.20240203"
types-requests = "^2.31.0.1"
types-python-dateutil = "^2.8.19.13"
types-certifi = "^2021.10.8.3"
types-s3transfer = "^0.6.1"
types-stripe = "^3.5.2.20240106"
types-boto3 = "^1.0.2"


[build-system]
requires = ["poetry-core>=1.5.1"]
build-backend = "poetry.core.masonry.api"

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "mysite.settings"
python_files = "tests.py test_*.py *_tests.py"
testpaths = "app/tests"
addopts = "--cov=./ --cov-report=xml:./.test-reports/coverage.xml"

[tool.black]
line-length = 120

[tool.bandit]
exclude_dirs = ["tests"]

[tool.djlint]
ignore = "H021"
# Ignore H012 Inline Styles should be avoided

[tool.django-stubs]
django_settings_module = "mysite.settings"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment