Skip to content

Commit

Permalink
Update dockerfile for pi
Browse files Browse the repository at this point in the history
  • Loading branch information
daya0576 committed Oct 26, 2024
1 parent 6706d49 commit 701b30e
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
FROM python:3.12-slim AS builder

ARG TARGETPLATFORM

RUN echo "I'm building for $TARGETPLATFORM"
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC \
apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
build-essential libffi-dev libssl-dev curl

RUN python -m pip install --upgrade pip
# NiceGUI 1.4.20 - Make libsass optional
# RUN python -m pip install --upgrade libsass
RUN python -m pip install --upgrade cffi
# Additional steps for raspberry pi
RUN if [ "$TARGETPLATFORM" = "linux/arm/v7" ] || [ "$TARGETPLATFORM" = "linux/arm/v6" ]; then \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable; \
export PATH=/root/.cargo/bin:$PATH; \
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig; \
export OPENSSL_LIB_DIR=/usr/lib/arm-linux-gnueabihf; \
export OPENSSL_INCLUDE_DIR=/usr/include/arm-linux-gnueabihf/openssl; \
fi

FROM python:3.12-slim AS release
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
# Build dependencies
COPY requirements.txt ./
RUN python -m pip install --upgrade pip cffi && \
mkdir /wheels && \
pip wheel --no-cache-dir -r requirements.txt -w /wheels

FROM python:3.12-slim AS release
COPY --from=builder /wheels /wheels
LABEL maintainer="Henry Zhu <[email protected]>"

WORKDIR /app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir --no-index --find-links /wheels -r requirements.txt

COPY start.sh .
COPY beaverhabits ./beaverhabits
COPY statics ./statics
COPY start.sh .

CMD ["sh", "start.sh", "prd"]

0 comments on commit 701b30e

Please sign in to comment.