-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathDockerfile.python
More file actions
92 lines (69 loc) · 2.56 KB
/
Copy pathDockerfile.python
File metadata and controls
92 lines (69 loc) · 2.56 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
# docker build --build-arg CUDA_VERSION=12.4.1 --build-arg PYTHON_VERSION=3.12 -t semoss/pybuilder:ubutunu2204_py3.12 . -f Dockerfile.ubuntu2204
# Base image arguments
#ARG BASE_REGISTRY=docker.io
#ARG BASE_IMAGE=ubuntu
#ARG BASE_TAG=22.04
ARG BASE_REGISTRY
ARG BASE_IMAGE
ARG BASE_TAG
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS builder
ENV BASE_REGISTRY=${BASE_REGISTRY}
ENV BASE_IMAGE=${BASE_IMAGE}
ENV BASE_TAG=${BASE_TAG}
LABEL maintainer="[email protected]"
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libffi-dev \
git \
clang \
# python3-pip \
&& rm -rf /var/lib/apt/lists/*
# installing rust as some python packages now require it for compiling
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
# Set environment variables for uv
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
UV_NO_CACHE=1
# we will install python inside /usr/lib/python/semossvenv
# it is done here to carry forward and limit the duplicated chowns in opt
ENV VIRTUAL_ENV="/usr/lib/python/semossvenv"
ENV UV_PYTHON_INSTALL_DIR="/usr/lib/python"
ENV UV_INSTALL_DIR="/usr/lib/uv/"
ENV PATH=$UV_INSTALL_DIR:$PATH
ENV PATH=$VIRTUAL_ENV/bin:$PATH
# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
#ARG PYTHON_VERSION=3.12
ARG PYTHON_VERSION
ENV PYTHON_VERSION=${PYTHON_VERSION}
ARG COMPUTE_TYPE
ENV COMPUTE_TYPE=${COMPUTE_TYPE}
RUN uv python install ${PYTHON_VERSION} --default --preview
RUN uv venv --seed $VIRTUAL_ENV
RUN echo "COMPUTE_TYPE=${COMPUTE_TYPE}" && echo ".[${COMPUTE_TYPE}]"
RUN cd /tmp && \
curl -o pyproject.toml https://raw.githubusercontent.com/SEMOSS/Semoss/refs/heads/dev/py/install_config/pyproject.toml && \
uv pip install ".[${COMPUTE_TYPE}]" && \
uv pip install "levenshtein>=0.27.3"
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS final
COPY --from=builder /usr/lib/python /usr/lib/python
ENV VIRTUAL_ENV="/usr/lib/python/semossvenv"
ENV PATH=$VIRTUAL_ENV/bin:$PATH
# Install additional dependencies with retry for transient Ubuntu mirror issues
RUN rm -rf /var/lib/apt/lists/* \
&& for i in 1 2 3; do apt-get update && break || (sleep 10 && rm -rf /var/lib/apt/lists/*); done \
&& apt-get install -y --no-install-recommends --fix-missing tesseract-ocr \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*
# FROM scratch AS final
# COPY --from=builder / /
WORKDIR /opt
CMD ["bash"]