Skip to content

Commit

Permalink
Use multi-stage docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
smitpsanghavi committed Feb 1, 2025
1 parent 4765bca commit c16e45d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 28 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.git
.github
actions-data-download
patterns
screenshots
test
.dockerignore
.gitignore
**/*.md
**/*.spec
Dockerfile
LICENSE
Makefile
*.code-workspace
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ stock*.pkl
results*.pkl
*.spec
.DS_Store
.history/
.history/
*.code-workspace
55 changes: 33 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,58 @@
# Created : 17/08/2023
# Description : Dockerfile to build Screeni-py image for GUI release

FROM python:3.11.6-slim-bookworm as base
FROM python:3.11.6-slim-bookworm AS base

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y software-properties-common

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
vim nano wget curl \
&& \
git vim nano wget curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV LANG C.UTF-8
ENV LANG=C.UTF-8 \
PYTHONUNBUFFERED=TRUE \
PYTHONDONTWRITEBYTECODE=TRUE \
SCREENIPY_DOCKER=TRUE \
SCREENIPY_GUI=TRUE \
PATH=/opt/program:$PATH

# Build Phase
FROM base AS build

ADD . /opt/program/
ARG PIP_DISABLE_PIP_VERSION_CHECK=1
ARG PIP_NO_CACHE_DIR=1

ENV PATH="/opt/program:${PATH}"
# RUN apt-get update && apt-get install -y --no-install-recommends \
# build-essential

WORKDIR /opt/program

RUN chmod +x *
RUN python3 -m venv /venv
ENV PATH=/venv/bin:$PATH

COPY requirements.txt .

WORKDIR /opt/program/
RUN python3 -m pip install --upgrade pip
RUN --mount=type=cache,target=/root/.cache/pip pip3 install -r requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip pip3 install --no-deps advanced-ta

RUN pip3 install -r "requirements.txt"
RUN pip3 install --no-deps advanced-ta
# Package Phase
FROM base AS app

ENV PYTHONUNBUFFERED=TRUE
ENV PYTHONDONTWRITEBYTECODE=TRUE
COPY --from=build /venv /venv
ENV PATH=/venv/bin:$PATH

ENV SCREENIPY_DOCKER = TRUE
WORKDIR /opt/program

COPY . .

ENV SCREENIPY_GUI = TRUE
RUN chmod +x ./*

EXPOSE 8000
EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

WORKDIR /opt/program/src/
ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
WORKDIR /opt/program/src

ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
# ENTRYPOINT ["tail", "-f", "/dev/null"]
5 changes: 0 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ pep517
pip
pip-chill
progress
# pyinstaller==5.6.2
pytest-mock
pytoml
retrying
scipy==1.11.2
# ta-lib
TA-Lib-Precompiled
tabulate
# yfinance==0.1.87
yfinance==0.2.32
alive-progress==1.6.2
Pillow
Expand Down Expand Up @@ -60,9 +57,7 @@ toml # Installed as dependency for pep517, pytest
urllib3 # Installed as dependency for requests
webencodings # Installed as dependency for html5lib
pandas_ta
# protobuf==3.19.6
protobuf
# streamlit==1.26.0
streamlit
tensorflow
chromadb==0.4.10
Expand Down

0 comments on commit c16e45d

Please sign in to comment.