-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unnecessary dependencies Add docker build platforms debug docker image debug docker image resolve cffi issue resolve cargo issue refine docker image Separate docker pipeline Add new pipeline Add new pipeline Add pull option debug matrix fix typo fix typo test matrix test matrix test matrix test matrix test matrix test matrix test matrix test matrix test metrixs test metrix test metrix test metrix test metrix test metrix test metrix test metrix test metrix test metrix
- Loading branch information
Showing
7 changed files
with
171 additions
and
126 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
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
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,41 +1,70 @@ | ||
FROM python:3.12-slim AS builder | ||
|
||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC \ | ||
apt-get install -y --no-install-recommends \ | ||
build-essential libffi-dev libssl-dev curl | ||
# && rm -rf /var/lib/apt/lists/* \ | ||
# && apt-get clean | ||
FROM python:3.12-slim AS python-base | ||
|
||
ENV PYTHONUNBUFFERED=1 \ | ||
PYTHONDONTWRITEBYTECODE=1 \ | ||
\ | ||
PIP_NO_CACHE_DIR=off \ | ||
PIP_DISABLE_PIP_VERSION_CHECK=on \ | ||
PIP_DEFAULT_TIMEOUT=100 \ | ||
\ | ||
POETRY_VERSION=1.8.4 \ | ||
POETRY_HOME="/opt/poetry" \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=true \ | ||
POETRY_NO_INTERACTION=1 \ | ||
\ | ||
PYSETUP_PATH="/opt/pysetup" \ | ||
VENV_PATH="/opt/pysetup/.venv" | ||
|
||
# prepend poetry and venv to path | ||
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH" | ||
|
||
|
||
################################ | ||
# BUILDER-BASE | ||
# Used to build deps + create our virtual environment | ||
################################ | ||
FROM python-base AS builder-base | ||
RUN apt-get update \ | ||
&& apt-get install --no-install-recommends -y \ | ||
build-essential libffi-dev libssl-dev curl | ||
|
||
# Installing a cryptography dependency which requires Rust. | ||
# TODO: Enable only for arm/v7 | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable | ||
ENV PATH=/root/.cargo/bin:$PATH | ||
ENV PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig | ||
ENV OPENSSL_LIB_DIR=/usr/lib/arm-linux-gnueabihf | ||
ENV OPENSSL_INCLUDE_DIR=/usr/include/arm-linux-gnueabihf/openssl | ||
# install poetry - respects $POETRY_VERSION & $POETRY_HOME | ||
RUN pip install cffi | ||
RUN pip install poetry | ||
# copy project requirement files here to ensure they will be cached. | ||
WORKDIR $PYSETUP_PATH | ||
COPY poetry.lock pyproject.toml ./ | ||
# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally | ||
RUN poetry install --only main | ||
|
||
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 | ||
COPY requirements.txt ./ | ||
RUN mkdir /wheels | ||
RUN pip wheel --no-cache-dir -r requirements.txt -w /wheels | ||
# [Experimental] Remove unused nicegui libs | ||
ENV NICEGUI_LIB_PATH="/opt/pysetup/.venv/lib/python3.12/site-packages/nicegui/elements/lib" | ||
RUN rm -rf "$NICEGUI_LIB_PATH/mermaid/" | ||
RUN rm -rf "$NICEGUI_LIB_PATH/plotly/" | ||
RUN rm -rf "$NICEGUI_LIB_PATH/vanilla-jsoneditor/" | ||
|
||
FROM python:3.12-slim AS release | ||
COPY --from=builder /wheels /wheels | ||
|
||
LABEL maintainer="Henry Zhu <[email protected]>" | ||
################################ | ||
# PRODUCTION | ||
# Final image used for runtime | ||
################################ | ||
FROM python-base AS production | ||
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH | ||
|
||
WORKDIR /app | ||
COPY 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 | ||
|
||
RUN chmod -R g+w /app && \ | ||
chown -R nobody /app | ||
|
||
USER nobody | ||
|
||
CMD ["sh", "start.sh", "prd"] |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.