-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (48 loc) · 1.86 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (48 loc) · 1.86 KB
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
FROM python:3.11-slim
WORKDIR /srv
# System Dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
tesseract-ocr \
tesseract-ocr-deu \
libgl1 \
poppler-utils \
build-essential \
curl && \
rm -rf /var/lib/apt/lists/*
# Install UV
# Pin the version of uv for reproducible builds, 0.1.41
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# Dependencies Layer --no-dev
COPY pyproject.toml uv.lock* /srv/
# Install dependencies with pip via uv
# '--system' to install into the main Python environment
# '--extra-index-url' to find CPU versions of Torch
# '-r pyproject.toml' so uv reads requirements directly
RUN uv pip install --system --no-cache \
--extra-index-url https://download.pytorch.org/whl/cpu \
-r pyproject.toml
# Application Code Layer
# Because of .dockerignore, this will NOW only copy the files
COPY . /srv/
# Install the package (Removed '-e')
RUN uv pip install --system --no-deps .
ENV PYTHONPATH=/srv
# Create non-root user for security
#RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /srv
#USER appuser
EXPOSE 8080
CMD ["uvicorn", "app.api.api:app", "--host", "0.0.0.0", "--port", "8080"]
# docker build -t german-document-classifier .
# docker run -p 8080:8080 german-document-classifier
# docker run -it --rm german-document-classifier /bin/bash
# clean up failed builds and old images
# docker system prune -a
# docker build -t german-classifier:debug .
# docker build --no-cache -t german-classifier:debug .
# docker run -it --rm german-classifier:debug /bin/bash
# docker run -p 8080:8080 german-classifier:debug
# curl http://localhost:8080/models
# docker build --no-cache --platform linux/amd64 -t myapp . # testing in digital ocean or other linux platforms
# docker tag myapp:latest usr6706/myapp:latest
# docker push usr6706/myapp:latest