-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |