Skip to content

Commit

Permalink
Build modelbuilder in docker
Browse files Browse the repository at this point in the history
Builds the sdist for model-builder in docker, by copying
in the .git folder so it can deduce the version. The sdist
tar.gz is then copied into a new docker image for the actual
serving, where it and its requirements are installed.
  • Loading branch information
Erik Parmann authored and epa095 committed Nov 19, 2018
1 parent b3714d1 commit f07c4cd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
24 changes: 17 additions & 7 deletions Dockerfile-ModelBuilder
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
FROM python:3.6.6-slim-stretch
FROM python:3.6.6 as builder

# Copy source code
COPY . /code
# Copy .git to deduce version number
COPY .git /code/

RUN mkdir /data
WORKDIR /code
RUN python setup.py sdist && \
mv /code/dist/$(ls /code/dist | head -1) /code/dist/gordo-components-packed.tar.gz

FROM python:3.6.6-slim-stretch

# Install requirements separately for improved docker caching
COPY requirements.txt /code/
RUN pip install -r /code/requirements.txt

# Copy source code
COPY . /code

# Install gordo-components, packaged from earlier 'python setup.py sdist'
RUN pip install /code/dist/$(ls /code/dist | head -1)
ADD build.sh /code/build.sh

# build.sh (build the model) as executable default command
RUN cp /code/build.sh /usr/bin/build \
&& chmod +x /usr/bin/build

# Install gordo-components, packaged from earlier 'python setup.py sdist'
COPY --from=builder /code/dist/gordo-components-packed.tar.gz .

RUN pip install ./gordo-components-packed.tar.gz

CMD ["build"]
17 changes: 13 additions & 4 deletions Dockerfile-ModelServer
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
FROM seldonio/seldon-core-s2i-python3
FROM python:3.6.6 as builder

# Copy source code
COPY . /code
# Copy .git to deduce version number
COPY .git /code/

RUN mkdir /code
WORKDIR /code
RUN python setup.py sdist && \
mv /code/dist/$(ls /code/dist | head -1) /code/dist/gordo-components-packed.tar.gz

FROM seldonio/seldon-core-s2i-python3

# Install requirements separately for improved docker caching
COPY requirements.txt /code/
RUN pip install -r /code/requirements.txt

COPY . /code
COPY --from=builder /code/dist/gordo-components-packed.tar.gz .

# Install gordo-components, packaged from earlier 'python setup.py sdist'
RUN pip install /code/dist/$(ls /code/dist | head -1)
RUN pip install ./gordo-components-packed.tar.gz
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ push-prod-images: push-builder push-server

# Make the python source distribution
sdist:
# Ensure the dist directory is empty/non-existant before sdist
# Ensure the dist directory is empty/non-existant before sdist
rm -rf ./dist/
python setup.py sdist

images: sdist model-builder model-server
images: model-builder model-server

test:
python setup.py test
Expand Down

0 comments on commit f07c4cd

Please sign in to comment.