Skip to content

Commit 3f25370

Browse files
committed
Section 11.3 - Dockerfile Setup
1 parent bd602b2 commit 3f25370

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

.dockerignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
jupyter_notebooks*
2+
*/env*
3+
*/venv*
4+
.circleci*
5+
packages/regression_model
6+
*.env
7+
*.log
8+
.git
9+
.gitignore

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM python:3.6.4
2+
3+
# Create the user that will run the app
4+
RUN adduser --disabled-password --gecos '' ml-api-user
5+
6+
WORKDIR /opt/ml_api
7+
8+
ARG PIP_EXTRA_INDEX_URL
9+
ENV FLASK_APP run.py
10+
11+
# Install requirements, including from Gemfury
12+
ADD ./packages/ml_api /opt/ml_api/
13+
RUN pip install --upgrade pip
14+
RUN pip install -r /opt/ml_api/requirements.txt
15+
16+
RUN chmod +x /opt/ml_api/run.sh
17+
RUN chown -R ml-api-user:ml-api-user ./
18+
19+
USER ml-api-user
20+
21+
EXPOSE 5000
22+
23+
CMD ["bash", "./run.sh"]

packages/ml_api/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
export IS_DEBUG=${DEBUG:-false}
3+
exec gunicorn -b :${PORT:-5000} --access-logfile - --error-logfile - run:application

0 commit comments

Comments
 (0)