Skip to content

Commit

Permalink
Converting hosted demos images to multi-stage builds
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanMullins committed Aug 12, 2024
1 parent 49b7975 commit a0d7b23
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ jobs:
- name: Build Docker image
uses: docker/build-push-action@v4
with:
target: lit-nlp-prod
tags: lit-nlp:ci-${{ github.sha }}
37 changes: 28 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,44 @@
# ==============================================================================
# Use the official lightweight Python image.
# https://hub.docker.com/_/python
FROM python:3.10-slim

# ---- LIT Base Container ----

FROM python:3.11-slim AS lit-nlp-base

# Update Ubuntu packages and install basic utils
RUN apt-get update
RUN apt-get install -y wget curl gnupg2 gcc g++ git

# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME

COPY ./lit_nlp/examples/gunicorn_config.py ./



# ---- LIT Container for Hosted Demos ----

FROM lit-nlp-base AS lit-nlp-prod

RUN python -m pip install 'lit-nlp[examples]'

WORKDIR $APP_HOME
ENTRYPOINT ["gunicorn", "--config=gunicorn_config.py"]



# ---- LIT Container for Developing and Testing Hosted Demos ----

FROM lit-nlp-base AS lit-nlp-dev

# Install yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | \
tee /etc/apt/sources.list.d/yarn.list
RUN apt update && apt -y install yarn

# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME

# Set up python environment with production dependencies
# This step is slow as it installs many packages.
COPY ./requirements*.txt ./
Expand All @@ -47,7 +69,4 @@ RUN yarn && yarn build && rm -rf node_modules/*
# Note that the config file supports configuring the LIT demo that is launched
# via the DEMO_NAME and DEMO_PORT environment variables.
WORKDIR $APP_HOME
ENTRYPOINT [ \
"gunicorn", \
"--config=lit_nlp/examples/gunicorn_config.py" \
]
ENTRYPOINT ["gunicorn", "--config=gunicorn_config.py"]

0 comments on commit a0d7b23

Please sign in to comment.