-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
126 lines (99 loc) · 4.16 KB
/
Copy pathDockerfile
File metadata and controls
126 lines (99 loc) · 4.16 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# syntax=docker/dockerfile:1
ARG RUST_VERSION=1.95
ARG PYTHON_VERSION=3.12
FROM rust:${RUST_VERSION}-bookworm AS rust-builder
RUN apt-get update \
&& apt-get install --yes --no-install-recommends build-essential pkg-config \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build/tq
COPY tq/ ./
RUN mkdir -p /tmp/tq-test-home \
&& HOME=/tmp/tq-test-home cargo test --locked --release \
&& cargo build --locked --release
FROM python:${PYTHON_VERSION}-slim-bookworm AS python-base
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
LABEL_CHECK_CONTAINER=true \
EASYOCR_FORCE_CPU=true \
EASYOCR_MODEL_DIR=/opt/easyocr-models \
HOME=/home/labelcheck \
TQ_HOME_DIR=/home/labelcheck/.tq
RUN apt-get update \
&& apt-get install --yes --no-install-recommends \
ca-certificates \
curl \
gnupg \
libglib2.0-0 \
libgl1 \
libgomp1 \
libopenslide0 \
libsm6 \
libxext6 \
krb5-user \
unixodbc \
&& curl -fsSL https://packages.microsoft.com/keys/microsoft.asc \
| gpg --dearmor --yes --output /usr/share/keyrings/microsoft-prod.gpg \
&& curl -fsSL https://packages.microsoft.com/config/debian/12/prod.list \
-o /etc/apt/sources.list.d/microsoft-prod.list \
&& apt-get update \
&& ACCEPT_EULA=Y apt-get install --yes --no-install-recommends msodbcsql18 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install --disable-pip-version-check --upgrade pip
COPY requirements.txt ./requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install --disable-pip-version-check \
--require-hashes \
--requirement requirements.txt
RUN mkdir -p "$EASYOCR_MODEL_DIR" \
&& python -c "import easyocr; easyocr.Reader(['en'], gpu=False, model_storage_directory='$EASYOCR_MODEL_DIR')"
# Source edits should invalidate only these inexpensive layers, not Python
# dependencies or the downloaded OCR models above.
COPY src/ ./src/
COPY tests/ ./tests/
COPY --chmod=0755 container/entrypoint.sh ./container/entrypoint.sh
COPY nightly_label_check.py requirements-test.txt requirements-windows-worker.txt ./
RUN sed -i 's/\r$//' /app/container/entrypoint.sh \
&& /bin/sh -n /app/container/entrypoint.sh
FROM python-base AS test
COPY compose.yaml ./compose.yaml
COPY container/caddy/ ./container/caddy/
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install --disable-pip-version-check \
--require-hashes \
--requirement requirements-test.txt \
&& python -m pip check \
&& python -W error::ResourceWarning -m unittest discover \
--start-directory tests --verbose
FROM python-base AS runtime
COPY --from=rust-builder /build/tq/target/release/tq /app/bin/tq
RUN groupadd --gid 10001 labelcheck \
&& useradd --uid 10001 --gid labelcheck --create-home labelcheck \
&& mkdir -p /data/state/instance /home/labelcheck/.ssh /home/labelcheck/.tq \
&& sha256sum /app/bin/tq > /app/bin/tq.sha256 \
&& chown -R labelcheck:labelcheck /app /data/state /home/labelcheck \
&& sh -c '/app/bin/tq >/dev/null 2>&1; test "$?" -eq 1'
ENV TQ_EXECUTABLE=/app/bin/tq \
INSTANCE_DIR=/data/state/instance \
SDL_FILE_PATH=/data/state/Slide_Digitization_Log.xlsx \
BACKUP_DIR=/data/state/csv_backups \
SCANNER_INVENTORIES=/data/scanner-inventories \
LABEL_CHECK_BATCHES=/data/label-check-batches \
IMAGE_STAGING_ROOT=/data/image-staging \
COPATH_CLONE=/data/copath-clone \
TQ_TRANSFER_LOG_DIR=/data/label-check-batches/transfer_logs \
GT450_IMAGES_CONTAINER_ROOT=/data/gt450-images \
LABEL_CHECK_BATCHES_CONTAINER_ROOT=/data/label-check-batches \
COPATH_QUERY_MODE=windows_queue \
COPATH_QUERY_QUEUE=/data/state/copath-query \
COPATH_QUERY_TIMEOUT_SECONDS=300 \
PORT=5000
WORKDIR /app/src
USER labelcheck
EXPOSE 5000
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:5000/login', timeout=5)" || exit 1
ENTRYPOINT ["/app/container/entrypoint.sh"]
CMD ["web"]