-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdockerfile
More file actions
69 lines (56 loc) · 1.89 KB
/
Copy pathdockerfile
File metadata and controls
69 lines (56 loc) · 1.89 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
# syntax=docker/dockerfile:1
FROM python:3.13-slim-bookworm AS dependency-image
# Copy package
COPY . /pkg
# Create a virtual env
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install the package with the CI test-image data-stack constraint. Every
# dependency must resolve to a wheel because the image has no compiler.
# pyarrow is an optional (requirements-full.txt) dependency of the package
# itself, but this image's smoke test exercises it directly to validate
# NumPy/Pandas/PyArrow wheel interop, so it's installed explicitly here.
RUN python -m pip install \
--no-cache-dir \
--only-binary=:all: \
--constraint /pkg/constraints/test-container-python313.txt \
/pkg packaging pyarrow
# Retain only the Botocore data used by the S3 connector and remove Pandas test
# data. Resolve installed-package locations instead of embedding a Python minor.
RUN python - <<'PY'
from pathlib import Path
import shutil
import botocore
import pandas
botocore_data = Path(botocore.__file__).resolve().parent / "data"
keep = {
"s3",
"_retry.json",
"endpoints.json",
"partitions.json",
"sdk-default-configuration.json",
}
for path in botocore_data.iterdir():
if path.name in keep:
continue
if path.is_dir():
shutil.rmtree(path)
else:
path.unlink()
pandas_tests = Path(pandas.__file__).resolve().parent / "tests"
if pandas_tests.exists():
shutil.rmtree(pandas_tests)
PY
# Fail the build before the runtime stage if versions, metadata, package-data
# trimming, imports, or the credential-free data/S3 checks are incorrect.
RUN python -m pip check \
&& python /pkg/scripts/container_smoke.py
# Create build image
FROM python:3.13-slim-bookworm AS build-image
COPY --from=dependency-image /opt/venv /opt/venv
LABEL maintainer="WrangleWorks"
ENV PATH="/opt/venv/bin:$PATH"
RUN mkdir /app
COPY main.py /app/
WORKDIR /app/
CMD python main.py