Skip to content

Commit 97090ca

Browse files
Merge delphi_web_python Docker image from operations repo (#1043)
- remove delphi_python Docker image - merge operations repo delphi_python Dockerfile into delphi_web_python - copy Python requirements file to this directory and merge with requirements.dev.txt - copy setup.sh to this directory - renamed requirements.txt to requirements.api.txt - remove unused Docker commands from CI - merge requirements files and pin versions and sort and remove unused packages (#1046) Co-authored-by: melange396 <[email protected]> Co-authored-by: Dmitry Shemetov <[email protected]>
1 parent 9d97fe7 commit 97090ca

File tree

7 files changed

+78
-36
lines changed

7 files changed

+78
-36
lines changed

.github/workflows/ci.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ jobs:
5151

5252
- name: Build docker images
5353
run: |
54-
docker build -t delphi_python -f repos/delphi/operations/dev/docker/python/Dockerfile .
5554
docker build -t delphi_database_epidata -f ./repos/delphi/delphi-epidata/dev/docker/database/epidata/Dockerfile .
5655
docker build -t delphi_web_python -f repos/delphi/delphi-epidata/dev/docker/python/Dockerfile .
5756
cd ./repos/delphi/delphi-epidata

dev/docker/python/Dockerfile

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# start with the `delphi_python` image, which is built from repos/delphi/operations/dev/docker/python/Dockerfile
2-
FROM delphi_python
1+
FROM python:3.8-buster
32

4-
RUN pip install --no-cache-dir -r repos/delphi/delphi-epidata/requirements.txt -r repos/delphi/delphi-epidata/requirements.dev.txt
3+
WORKDIR /usr/src/app
4+
5+
COPY repos repos
6+
COPY repos/delphi/delphi-epidata/dev/docker/python/setup.sh .
7+
8+
RUN ln -s -f /usr/share/zoneinfo/America/New_York /etc/localtime && \
9+
chmod -R o+r repos/ && \
10+
bash setup.sh && \
11+
pip install --no-cache-dir -r repos/delphi/delphi-epidata/requirements.api.txt -r repos/delphi/delphi-epidata/requirements.dev.txt

dev/docker/python/setup.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This script sets up the correct directory structure within the `delphi_img`
2+
# docker image.
3+
4+
# Some notes on package structure:
5+
# - Python package names can't contain hyphens, so hyphens in repo names are
6+
# replaced with underscores in the package hierarchy. (An exception is the
7+
# repo `delphi-epidata`, which is renamed to simply `epidata`.)
8+
# - Repos are organized such that the main code for the package is inside of
9+
# a `src/` directory. When deployed, `src/` is elided. (An exception is the
10+
# legacy `undef-analysis` repo, which has sources at the top-level.)
11+
12+
# bail if anything fails
13+
set -e
14+
15+
# create python package `undefx`
16+
mkdir undefx
17+
mv repos/undefx/py3tester/src undefx/py3tester
18+
mv repos/undefx/undef-analysis undefx/undef_analysis
19+
20+
# create python package `delphi`
21+
mkdir delphi
22+
mv repos/delphi/operations/src delphi/operations
23+
mv repos/delphi/utils/src delphi/utils
24+
mv repos/delphi/github-deploy-repo/src delphi/github_deploy_repo
25+
mv repos/delphi/delphi-epidata/src delphi/epidata
26+
mv repos/delphi/flu-contest/src delphi/flu_contest
27+
mv repos/delphi/nowcast/src delphi/nowcast

dev/local/Makefile

-8
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
#
88
# Checks for the delphi-net bridge and creates if it doesn't exist.
99
#
10-
# Creates all prereq images (delphi_database, delphi_python) only if they don't
11-
# exist. If you need to rebuild a prereq, you're probably doing something
12-
# complicated, and can figure out the rebuild command on your own.
13-
#
1410
#
1511
# Commands:
1612
#
@@ -116,10 +112,6 @@ db:
116112

117113
.PHONY=py
118114
py:
119-
@# Build the python image
120-
@docker build -t delphi_python \
121-
-f repos/delphi/operations/dev/docker/python/Dockerfile .
122-
123115
@docker build -t delphi_web_python \
124116
-f repos/delphi/delphi-epidata/dev/docker/python/Dockerfile .
125117

devops/Dockerfile

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ RUN npm ci && npm run build
55

66
FROM tiangolo/meinheld-gunicorn:python3.8
77
LABEL org.opencontainers.image.source=https://github.com/cmu-delphi/delphi-epidata
8-
# use delphi's timezome
9-
RUN ln -s -f /usr/share/zoneinfo/America/New_York /etc/localtime
108

11-
COPY requirements.txt /app/requirements_also.txt
12-
RUN pip install --no-cache-dir -r /tmp/requirements.txt -r requirements_also.txt
9+
COPY ./devops/gunicorn_conf.py /app
10+
COPY ./devops/start_wrapper.sh /
11+
COPY ./src/server/ /app/app/
12+
COPY --from=builder ./src/build/lib/ /app/app/lib/
13+
14+
COPY requirements.api.txt /app/requirements_also.txt
15+
16+
RUN ln -s -f /usr/share/zoneinfo/America/New_York /etc/localtime \
17+
&& rm -rf /app/app/__pycache__ /app/app/*.php \
18+
&& chmod -R o+r /app/app \
19+
&& chmod 755 /start_wrapper.sh \
20+
&& pip install --no-cache-dir -r /tmp/requirements.txt -r requirements_also.txt
1321
# the file /tmp/requirements.txt is created in the parent docker definition. (see:
1422
# https://github.com/tiangolo/meinheld-gunicorn-docker/blob/master/docker-images/python3.8.dockerfile#L5 )
1523
# this combined requirements installation ensures all version constrants are accounted for.
1624

1725
# disable python stdout buffering
1826
ENV PYTHONUNBUFFERED 1
1927

20-
COPY ./devops/gunicorn_conf.py /app
21-
COPY ./devops/start_wrapper.sh /
22-
COPY ./src/server/ /app/app/
23-
COPY --from=builder ./src/build/lib/ /app/app/lib/
24-
RUN rm -rf /app/app/__pycache__ /app/app/*.php \
25-
&& chmod -R o+r /app/app \
26-
&& chmod 755 /start_wrapper.sh
27-
2828
ENTRYPOINT [ "/entrypoint.sh" ]
2929
CMD [ "/start_wrapper.sh" ]
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
epiweeks==2.1.2
2+
Flask==2.2.2
13
itsdangerous<2.1
24
jinja2==3.0.3
3-
werkzeug==2.2.2
4-
Flask==2.2.2
5-
SQLAlchemy==1.4.40
65
mysqlclient==2.1.1
7-
python-dotenv==0.15.0
6+
newrelic
87
orjson==3.4.7
98
pandas==1.2.3
9+
python-dotenv==0.15.0
1010
scipy==1.6.2
11+
SQLAlchemy==1.4.40
12+
structlog==22.1.0
1113
tenacity==7.0.0
12-
newrelic
13-
epiweeks==2.1.2
1414
typing-extensions
15-
structlog==22.1.0
15+
werkzeug==2.2.2

requirements.dev.txt

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
invoke>=1.4.1
1+
aiohttp==3.8.3
22
black>=20.8b1
3-
sqlalchemy-stubs>=0.3
3+
bump2version==1.0.1
4+
covidcast==0.1.5
5+
delphi_utils==0.3.6
6+
docker==6.0.1
7+
dropbox==11.36.0
8+
freezegun==1.2.2
9+
invoke>=1.4.1
10+
lxml==4.9.1
11+
matplotlib==3.6.2
412
mypy>=0.790
5-
pytest
13+
mysql-connector==2.2.9
14+
numpy==1.22.4
15+
pycountry==22.3.5
16+
pymysql==1.0.2
17+
pytest==7.2.0
18+
pytest-check==1.3.0
19+
requests==2.28.1
20+
sas7bdat==2.2.3
21+
selenium==4.7.2
22+
sqlalchemy-stubs>=0.3
23+
structlog==22.1.0
624
tenacity==7.0.0
7-
bump2version
8-
requests
25+
xlrd==2.0.1

0 commit comments

Comments
 (0)