Skip to content

Instantly share code, notes, and snippets.

@JohnBat26
Created January 18, 2021 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnBat26/6c09c55980ce91904ebc02524dbc0722 to your computer and use it in GitHub Desktop.
Save JohnBat26/6c09c55980ce91904ebc02524dbc0722 to your computer and use it in GitHub Desktop.
rasa-for-botfront Dockerfile
FROM python:3.8-slim as base
RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends \
# required by psycopg2 at build and runtime
libpq-dev \
# required for health check
curl \
&& apt-get autoremove -y
FROM base as builder
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
build-essential \
wget \
openssh-client \
graphviz-dev \
pkg-config \
git-core \
openssl \
libssl-dev \
libffi6 \
libffi-dev \
libpng-dev
# install poetry
# keep this in sync with the version in pyproject.toml and Dockerfile
ENV POETRY_VERSION 1.0.5
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
ENV PATH "/root/.poetry/bin:/opt/venv/bin:${PATH}"
# copy files
COPY . /build/
# change working directory
WORKDIR /build
# install dependencies
RUN python -m venv /opt/venv && \
. /opt/venv/bin/activate && \
pip install --no-cache-dir -U 'pip<20' && \
pip install --ignore-installed --upgrade packages/tensorflow-2.3.1-cp38-cp38-linux_x86_64.whl && \
poetry install --no-dev --no-root --no-interaction && \
pip install sgqlc && \
poetry build -f wheel -n && \
pip install --no-deps dist/*.whl && \
rm -rf dist packages *.egg-info
# start a new build stage
FROM base as runner
# copy everything from /opt
COPY --from=builder /opt/venv /opt/venv
# make sure we use the virtualenv
ENV PATH="/opt/venv/bin:$PATH"
# update permissions & change user to not run as root
WORKDIR /app
RUN chgrp -R 0 /app && chmod -R g=u /app
USER 1001
# create a volume for temporary data
VOLUME /tmp
# change shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# the entry point
EXPOSE 5005
ENTRYPOINT ["rasa"]
CMD ["--help"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment