Skip to content

Commit 07e88fa

Browse files
committed
Add Docker
1 parent 9740d54 commit 07e88fa

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
README.md
2+
LICENSE.md
3+
note.txt
4+
images/
5+
ldlib_mrn/

Dockerfile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#Build stage
2+
ARG PYTHON_VERSION=3.11
3+
ARG VARIANT=slim-bookworm
4+
FROM python:${PYTHON_VERSION}-slim-bookworm AS builder
5+
6+
LABEL maintainer="LSEG Developer Relations"
7+
8+
#Copy requirements.txt
9+
COPY requirements.txt .
10+
11+
# install dependencies to the local user directory (eg. /root/.local)
12+
#RUN pip install --no-cache-dir --user -r requirements.txt
13+
RUN pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --no-cache-dir --user -r requirements.txt
14+
15+
# Run stage
16+
FROM python:${PYTHON_VERSION}-alpine3.20
17+
WORKDIR /app
18+
19+
# Update PATH environment variable + set Python buffer to make Docker print every message instantly.
20+
ENV PATH=/root/.local:$PATH \
21+
PYTHONUNBUFFERED=1\
22+
PYTHONIOENCODING=utf-8\
23+
PYTHONLEGACYWINDOWSSTDIO=utf-8
24+
25+
# copy only the dependencies installation from the 1st stage image
26+
COPY --from=builder /root/.local /root/.local
27+
COPY src/* .
28+
29+
#Run Python
30+
ENTRYPOINT ["python", "OMMStream-MRN-LD.py"]

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,24 @@ It is an advisable to create a dedicate Python environment to run each Python pr
135135

136136
If you are using the [Anaconda](https://anaconda.org/anaconda/conda)/[Miniconda](https://docs.anaconda.com/miniconda/) Python distribution, please refer to the [Conda document](https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html) about how to create a virtual environment using Conda.
137137

138+
## <a id="how_to_run_docker"></a>Bonus: How to run this example with Docker
139+
140+
1. Setup the ```src/lseg_data.config.json``` file based on your preference like the instructions above
141+
2. Go to the project folder in the console
142+
3. Run the following command in a console to build an image from a Dockerfile.
143+
144+
```bash
145+
$> docker build -t mrn_python .
146+
```
147+
148+
4. Once the build is a success, you can create and run the container with the following command
149+
150+
```bash
151+
$> docker run --name mrn_python -it mrn_python mrn_python
152+
```
153+
154+
5. Press Ctrl+C buttons to stop the application
155+
138156
## Example Results
139157

140158
### MRN Data Refresh Message

0 commit comments

Comments
 (0)