Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
sim/docker/pii.Dockerfile at main · simstudioai/sim · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
simstudioai
sim
Repository navigation
Code
Issues
128
(128)
Pull requests
217
(217)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
sim
/
docker
/
pii.Dockerfile
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
67 lines (56 loc) · 3.06 KB
main
Breadcrumbs
sim
/
docker
/
pii.Dockerfile
Copy path
Top
File metadata and controls
Code
Blame
67 lines (56 loc) · 3.06 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#
========================================
#
Combined Presidio service (analyzer + anonymizer) on a single port (5001).
#
CPU spaCy NER + regex/checksum pattern recognizers.
#
#
Source files are COPY'd last so code edits never re-download deps or models.
#
========================================
FROM
python:3.12-slim-bookworm AS base
WORKDIR
/app
#
build-essential for any sdist that compiles native deps (e.g. blis/thinc).
RUN
--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
build-essential curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
#
Pinned Python deps. Separate layer so source edits don't reinstall them.
COPY
apps/pii/requirements.txt ./requirements.txt
RUN
--mount=type=cache,target=/root/.cache/pip \
pip install -r requirements.txt
#
Pinned spaCy models (en + es/it/pl/fi, ~2.2GB total). Downloaded with
#
retries/resume — the large wheels truncate on flaky networks if pip fetches
#
the URLs directly.
ARG
SPACY_MODELS=
"en_core_web_lg-3.8.0 es_core_news_lg-3.8.0 it_core_news_lg-3.8.0 pl_core_news_lg-3.8.0 fi_core_news_lg-3.8.0"
RUN
--mount=type=cache,target=/root/.cache/pip \
for model in ${SPACY_MODELS}; do \
whl=
"${model}-py3-none-any.whl"
; \
curl -fL --retry 5 --retry-delay 5 --retry-all-errors -C - \
-o
"/tmp/${whl}"
\
"https://github.com/explosion/spacy-models/releases/download/${model}/${whl}"
|| exit 1; \
done && \
pip install /tmp/*.whl && \
rm /tmp/*.whl
RUN
groupadd -g 1001 pii && \
useradd -u 1001 -g pii pii && \
chown -R pii:pii /app
COPY
--chown=pii:pii apps/pii/server.py ./
COPY
--chown=pii:pii --chmod=755 docker/pii-entrypoint.sh ./
USER
pii
#
Listen on 5001. Runs as its own ECS service (separate task), reached via PII_URL;
#
5001 avoids colliding with the app's 3000 in local/compose runs on one host.
EXPOSE
5001
#
Per-pattern regex match timeout (Presidio's `regex`-module `finditer(timeout=...)`),
#
an interactive backstop against a catastrophic user-supplied custom regex. Presidio
#
logs and skips a pattern that exceeds it — the request stays up rather than hanging.
#
Set well below the 60s library default so a pathological pattern can't stall a worker.
#
MUST be an integer — Presidio parses it with `int()`, so a float (e.g. 1.5) crashes
#
the service at import.
ENV
REGEX_TIMEOUT_SECONDS=2
#
start-period covers the model cold start. With PII_WORKERS>1 each worker loads
#
the five spaCy models independently and in parallel, so allow generous headroom
#
(memory-bandwidth contention stretches the wall-time beyond the single-worker case).
HEALTHCHECK
--interval=30s --timeout=5s --start-period=300s --retries=3 \
CMD
curl -fsS http://localhost:5001/health || exit 1
#
Worker count is env-driven so ONE image scales per task size: set PII_WORKERS to
#
the task's vCPU count (each worker loads the models independently, ~3 GB each, so
#
size task memory ≈ PII_WORKERS × 3 GB + overhead). Defaults to 1 for local/small.
CMD
[
"./pii-entrypoint.sh"
]
You can’t perform that action at this time.