Repository navigation
Expand file tree
/
Copy pathDockerfile.beta
More file actions
74 lines (66 loc) · 2.71 KB
/
Copy pathDockerfile.beta
File metadata and controls
74 lines (66 loc) · 2.71 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
# TARGETARCH and TARGETVARIANT are injected automatically by buildx.
# They must be declared before the first FROM to be usable in FROM instructions.
# For linux/arm/v7: TARGETARCH=arm, TARGETVARIANT=v7 → selects base-armv7
# For linux/arm/v8: TARGETARCH=arm, TARGETVARIANT=v8 → selects base-armv8
# For linux/amd64: TARGETARCH=amd64, TARGETVARIANT="" → selects base-amd64
# For linux/arm64: TARGETARCH=arm64, TARGETVARIANT="" → selects base-arm64
ARG TARGETARCH
ARG TARGETVARIANT
# Base images per platform — arm/v7 and arm/v8 (32-bit ARM, Raspberry Pi) need
# slim-bookworm; amd64 and arm64 use the smaller alpine image.
FROM python:3.12-alpine AS base-amd64
FROM python:3.12-alpine AS base-arm64
FROM python:3.12-slim-bookworm AS base-armv7
FROM python:3.12-slim-bookworm AS base-armv8
FROM base-${TARGETARCH}${TARGETVARIANT}
WORKDIR /app
# Install all requirements including pypowerwall (to pull in its transitive deps),
# then install the local pypowerwall's own deps (may be ahead of the pinned release).
# Copy the local pypowerwall source tree and shadow it via PYTHONPATH.
# Package manager differs by base image (apk on Alpine, apt on Debian).
COPY requirements.txt .
RUN if command -v apk > /dev/null; then \
apk add --no-cache --virtual .build-deps \
gcc \
python3-dev \
make \
automake \
autoconf \
libtool \
musl-dev \
linux-headers \
libffi-dev && \
apk add --no-cache wget && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir \
"protobuf>=3.20.0" python-dotenv pyroute2 \
python-dateutil requests-oauthlib websocket-client cryptography && \
apk del .build-deps; \
else \
apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
python3-dev \
libffi-dev \
make \
automake \
autoconf \
libtool && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir \
"protobuf>=3.20.0" python-dotenv pyroute2 \
python-dateutil requests-oauthlib websocket-client cryptography && \
apt-get purge -y gcc python3-dev libffi-dev make automake autoconf libtool && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*; \
fi
# Copy local pypowerwall source tree — shadows the pip-installed version via PYTHONPATH
COPY pypowerwall/ ./pypowerwall/
# Ensure /app is first on the Python path so local pypowerwall/ is imported
ENV PYTHONPATH=/app
# Copy application
COPY app/ ./app/
# Expose port
EXPOSE 8675
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8675"]