-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
199 lines (154 loc) · 4.65 KB
/
Dockerfile
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
########################################################
# UBUNTU STAGE #
########################################################
FROM ubuntu:24.04 AS builder
# PREVENT INTERACTIVE PROMPTS DURING BUILD
ENV DEBIAN_FRONTEND=noninteractive
# INSTALL SYSTEM DEPENDENCIES
RUN apt-get update && apt-get install -y \
software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update && apt-get install -y \
python3.12 \
python3.12-dev \
python3.12-venv \
python3-pip \
python3-setuptools \
git \
ffmpeg \
build-essential \
xclip \
xsel \
openjdk-17-jre \
bc \
&& rm -rf /var/lib/apt/lists/*
# SET WORKING DIRECTORY
WORKDIR /app
# CREATE AND ACTIVATE VIRTUAL ENVIRONMENT
ENV VIRTUAL_ENV=/opt/venv
RUN python3.12 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# UPGRADE PIP AND INSTALL BUILD DEPENDENCIES
RUN pip install --upgrade pip setuptools wheel && \
pip install --no-cache-dir numpy cython rich>=13.7.0
# PRE-INSTALL PROBLEMATIC DEPENDENCIES
RUN pip install --no-cache-dir \
psutil \
netifaces \
spacy==3.7.2 --no-deps && \
pip install --no-cache-dir spacy[all]==3.7.2
# DOWNLOAD SPACY MODEL
RUN python -m spacy download en_core_web_sm
# COPY PROJECT FILES
COPY . .
# INSTALL PROJECT IN EDITABLE MODE
RUN pip install -e .
# UBUNTU STAGE
FROM ubuntu:24.04 AS ubuntu
# PREVENT INTERACTIVE PROMPTS DURING BUILD
ENV DEBIAN_FRONTEND=noninteractive
# INSTALL RUNTIME DEPENDENCIES
RUN apt-get update && apt-get install -y \
software-properties-common \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update && apt-get install -y \
python3.12 \
python3.12-venv \
ffmpeg \
xclip \
xsel \
openjdk-17-jre \
bc \
&& rm -rf /var/lib/apt/lists/*
# COPY VIRTUAL ENV FROM BUILDER
ENV VIRTUAL_ENV=/opt/venv
COPY --from=builder $VIRTUAL_ENV $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# SET WORKING DIRECTORY
WORKDIR /app
# COPY PROJECT FILES FROM BUILDER
COPY --from=builder /app /app
# COPY AND MAKE TEST SCRIPT EXECUTABLE
COPY run_tests.sh /app/run_tests.sh
RUN chmod +x /app/run_tests.sh
# SET ENTRYPOINT TO TEST SCRIPT
ENTRYPOINT ["/app/run_tests.sh"]
########################################################
# MACOS STAGE #
########################################################
# MACOS STAGE (using slim python image as base)
FROM python:3.12-slim AS macos
# INSTALL SYSTEM DEPENDENCIES
RUN apt-get update && apt-get install -y \
ffmpeg \
default-jre \
git \
build-essential \
python3-dev \
bc \
&& rm -rf /var/lib/apt/lists/*
# SET WORKING DIRECTORY
WORKDIR /app
# CREATE AND ACTIVATE VIRTUAL ENVIRONMENT
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# UPGRADE PIP AND INSTALL BUILD DEPENDENCIES
RUN pip install --upgrade pip setuptools wheel && \
pip install --no-cache-dir numpy cython rich>=13.7.0
# PRE-INSTALL PROBLEMATIC DEPENDENCIES
RUN pip install --no-cache-dir \
psutil \
netifaces \
spacy[all]==3.7.2
# DOWNLOAD SPACY MODEL
RUN python -m spacy download en_core_web_sm
# COPY PROJECT FILES
COPY . .
# INSTALL PROJECT IN EDITABLE MODE
RUN pip install -e .
# COPY AND MAKE TEST SCRIPT EXECUTABLE
COPY run_tests.sh /app/run_tests.sh
RUN chmod +x /app/run_tests.sh
# SET ENTRYPOINT TO TEST SCRIPT
ENTRYPOINT ["/app/run_tests.sh"]
########################################################
# WINDOWS STAGE #
########################################################
FROM python:3.11-slim AS windows
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install build essentials and runtime dependencies
RUN apt-get update && apt-get install -y \
build-essential \
git \
ffmpeg \
default-jre \
bc \
&& rm -rf /var/lib/apt/lists/*
# SET WORKING DIRECTORY
WORKDIR /app
# Create and activate virtual environment
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# INSTALL BUILD DEPENDENCIES
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir numpy cython rich>=13.7.0
# PRE-INSTALL PROBLEMATIC DEPENDENCIES
RUN pip install --no-cache-dir \
psutil \
netifaces \
spacy[all]==3.7.2
# DOWNLOAD SPACY MODEL
RUN python -m spacy download en_core_web_sm
# COPY PROJECT FILES
COPY . .
# INSTALL PROJECT IN EDITABLE MODE
RUN pip install -e .
# COPY TEST SCRIPT
COPY run_tests.sh /app/run_tests.sh
RUN chmod +x /app/run_tests.sh
# SET ENTRYPOINT TO TEST SCRIPT
ENTRYPOINT ["bash", "/app/run_tests.sh"]