Skip to content

Commit bb71c81

Browse files
authored
Create Python virtual environment penv already in Docker
1 parent fea768c commit bb71c81

File tree

1 file changed

+29
-37
lines changed

1 file changed

+29
-37
lines changed

Dockerfile

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,45 @@ RUN pip install --upgrade pip uv
1212
ENV UV_SYSTEM_PYTHON=1
1313
ENV UV_CACHE_DIR=/.cache/uv
1414

15-
# Install system dependencies required by ESP-IDF tools
15+
# Install system dependencies
1616
RUN apt-get update && apt-get install -y \
1717
git wget flex bison gperf cmake ninja-build ccache \
1818
libffi-dev libssl-dev dfu-util libusb-1.0-0 \
19+
python3-dev python3-venv \
1920
&& rm -rf /var/lib/apt/lists/*
2021

21-
# Install Python dependencies required by idf_tools.py
22+
# Install Python dependencies system-wide
2223
RUN uv pip install --upgrade \
23-
click \
24-
setuptools \
25-
wheel \
26-
virtualenv \
27-
pyserial \
24+
click setuptools wheel virtualenv pyserial \
25+
cryptography pyparsing pyelftools \
2826
platformio
2927

30-
# Create all necessary directories with full permissions
31-
RUN mkdir -p /.platformio \
32-
/.cache \
33-
/penv \
34-
/.local \
35-
/tmp \
36-
/root/.platformio \
37-
&& chmod -R 777 /.platformio \
38-
/.cache \
39-
/penv \
40-
/.local \
41-
/tmp \
42-
/root \
43-
/usr/local/lib \
44-
/usr/local/bin
45-
46-
# Additional permissions after PlatformIO installation
47-
RUN chmod -R 777 /usr/local/lib/python*/site-packages/
48-
49-
# Init project
28+
# Create base directories with proper permissions
29+
RUN mkdir -p /.platformio /.cache /.local /tmp \
30+
&& chmod -R 777 /.platformio /.cache /.local /tmp \
31+
/usr/local/lib /usr/local/bin
32+
33+
# Pre-create and configure penv for ESP-IDF tools
34+
RUN mkdir -p /.platformio/penv && \
35+
python3 -m venv /.platformio/penv && \
36+
/.platformio/penv/bin/pip install --upgrade pip && \
37+
/.platformio/penv/bin/pip install \
38+
click setuptools wheel virtualenv pyserial \
39+
cryptography pyparsing pyelftools && \
40+
chmod -R 777 /.platformio/penv
41+
42+
# Copy project
5043
COPY init_pio_tasmota /init_pio_tasmota
5144

52-
# Install project dependencies with verbose output for debugging
53-
RUN cd /init_pio_tasmota &&\
54-
platformio upgrade &&\
55-
pio pkg update &&\
56-
pio run --verbose &&\
57-
cd ../ &&\
58-
rm -fr init_pio_tasmota &&\
59-
cp -r /root/.platformio / &&\
60-
chmod -R 777 /.platformio /.cache /.local &&\
61-
chmod -R 777 /usr/local/lib/python*/site-packages/
45+
# Install project dependencies
46+
RUN cd /init_pio_tasmota && \
47+
platformio upgrade && \
48+
pio pkg update && \
49+
pio run && \
50+
cd ../ && \
51+
rm -fr init_pio_tasmota && \
52+
cp -r /root/.platformio / && \
53+
chmod -R 777 /.platformio /.cache /.local
6254

6355
COPY entrypoint.sh /entrypoint.sh
6456

0 commit comments

Comments
 (0)