Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use multi-stage docker builds #247

Open
wants to merge 3 commits into
base: new-features
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
pranjal-joshi marked this conversation as resolved.
Show resolved Hide resolved
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
56 changes: 34 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,59 @@
# 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

ADD . /opt/program/
##############
# Build Phase
##############
FROM base AS build

ENV PATH="/opt/program:${PATH}"
ARG PIP_DISABLE_PIP_VERSION_CHECK=1
ARG PIP_NO_CACHE_DIR=1

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

ENV SCREENIPY_GUI = TRUE
COPY . .

RUN chmod +x ./*

EXPOSE 8000
pranjal-joshi marked this conversation as resolved.
Show resolved Hide resolved
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
pranjal-joshi marked this conversation as resolved.
Show resolved Hide resolved
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