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

Dockerized version #152

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Dockerized version #152

wants to merge 1 commit into from

Conversation

brownrw8
Copy link

@brownrw8 brownrw8 commented Mar 7, 2025

Created a Dockerfile which creates a reproducible container.
Also updated README w/ instructions.

@brownrw8 brownrw8 mentioned this pull request Mar 7, 2025

# Set default command with -u flag for unbuffered output
ENTRYPOINT ["poetry", "run", "python", "-u", "src/main.py"]
CMD ["--ticker", "AAPL,MSFT,NVDA"] # Optional default arguments
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a new line at end of file.

@@ -0,0 +1,34 @@
# Use Python 3.10 slim image as base
FROM python:3.10-slim
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May change it to python 3.13. Python 3.10 will be end of life next year.

@@ -126,6 +126,18 @@ You can optionally specify the start and end dates to backtest over a specific t
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01
```

## Using Docker

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the info to create a .env file first.

# Copy source code
COPY src/ src/
COPY .env .
COPY .gitignore .
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

COPY src/ src/
COPY .env .
COPY .gitignore .
COPY README.md .
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

COPY .env .
COPY .gitignore .
COPY README.md .
COPY LICENSE .
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

RUN apt-get update && apt-get install -y \
gcc \
python3-dev \
curl \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed when you use "pip install poetry"

curl \
&& rm -rf /var/lib/apt/lists/*

RUN curl -sSL https://install.python-poetry.org | python3 -
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use "pip install poetry" to get rid of curl

&& rm -rf /var/lib/apt/lists/*

RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="/root/.local/bin:$PATH"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can combine this with line 30 to remove this docker layer:

ENV PYTHONUNBUFFERED=1
PATH="/root/.local/bin:$PATH"

@r0b2g1t
Copy link

r0b2g1t commented Mar 9, 2025

I think this PR can be closed as PR #154 contains the Dockerfile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants