-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dockerfile for publishing image (#12)
* Updated dockerfile and CI * Updated Dockerfile to fix some problems * Fixed the copy of src/ * Update Dockerfile to see ls * Update Dockerfile to have the src folder * Update Dockerfile Reduce the nb of layers in the builder * Fix the CI to forbid the manual use of the action
- Loading branch information
1 parent
89e8fe6
commit 12284d2
Showing
4 changed files
with
114 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Build & Tests | ||
on: | ||
push: | ||
paths: | ||
- 'src/**' | ||
- '!*.md' | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
branches: | ||
- 'main' | ||
- 'release/v*' | ||
paths: | ||
- 'src/**' | ||
- '!*.md' | ||
schedule: | ||
- cron: '0 4 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11"] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install the project and run tests | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install .[test] | ||
pytest | ||
python -m mypy --ignore-missing-imports --allow-redefinition --no-strict-optional -p src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,61 @@ | ||
ARG base_image=nvidia/cuda:12.1.0-devel-ubuntu22.04 | ||
FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04 AS builder | ||
|
||
# base image | ||
FROM ${base_image} | ||
LABEL org.opencontainers.image.author="Agence Data Services" | ||
LABEL org.opencontainers.image.description="REST service happy-vllm" | ||
|
||
ENV APP_NAME="happy_vllm" | ||
ENV API_ENTRYPOINT="/happy_vllm/rs/v1" | ||
COPY prebuildfs / | ||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
LABEL maintainer="Agence Data Services" | ||
LABEL description="Service REST happy_vllm" | ||
# Install python common | ||
RUN install_packages software-properties-common | ||
|
||
RUN add-apt-repository -d -y 'ppa:deadsnakes/ppa' \ | ||
&& install_packages python3.11 python3.11-dev python3.11-venv python3-pip \ | ||
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 | ||
|
||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PIP_NO_CACHE_DIR=true \ | ||
APP_NAME="happy_vllm" \ | ||
API_ENTRYPOINT="/happy_vllm/rs/v1" | ||
|
||
RUN python -m venv /opt/venv \ | ||
&& pip install --upgrade pip | ||
ENV VIRTUAL_ENV="/opt/venv" PATH="/opt/venv/bin:${PATH}" | ||
|
||
WORKDIR /app | ||
|
||
# Install package | ||
COPY pyproject.toml pyproject.toml | ||
COPY setup.py setup.py | ||
COPY src/ src/ | ||
COPY requirements.txt requirements.txt | ||
COPY version.txt version.txt | ||
COPY pyproject.toml setup.py README.md requirements.txt version.txt /app | ||
COPY src/happy_vllm /app/src/happy_vllm | ||
|
||
RUN python -m pip install -r requirements.txt && python -m pip install . | ||
|
||
FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04 | ||
|
||
RUN add-apt-repository -d -y 'ppa:deadsnakes/ppa' | ||
RUN install_packages python3.11 python3.11-dev python3.11-venv python3-pip | ||
COPY prebuildfs / | ||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
RUN ln -sfn /usr/bin/python3.11 /usr/bin/python3 | ||
# Install python common | ||
RUN install_packages software-properties-common | ||
|
||
RUN add-apt-repository -d -y 'ppa:deadsnakes/ppa' \ | ||
&& install_packages python3.11 \ | ||
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1 | ||
|
||
ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
PYTHONUNBUFFERED=1 \ | ||
PATH="/opt/venv/bin:${PATH}" \ | ||
PIP_NO_CACHE_DIR=true \ | ||
APP_NAME="happy_vllm" \ | ||
API_ENTRYPOINT="/happy_vllm/rs/v1" | ||
|
||
COPY --from=builder /opt/venv /opt/venv | ||
|
||
WORKDIR /app | ||
|
||
RUN python3 -m pip install --upgrade pip && python3 -m pip install -r requirements.txt && python3 -m pip install . | ||
COPY src/happy_vllm/launch.py /app | ||
|
||
# Start API | ||
EXPOSE 8501 | ||
CMD ["python3", "src/happy_vllm/launch.py"] | ||
EXPOSE 8000 | ||
CMD ["python", "/app/launch.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
n=0 | ||
max=2 | ||
export DEBIAN_FRONTEND=noninteractive | ||
export MKUSER="" | ||
|
||
until [ $n -gt $max ]; do | ||
set +e | ||
( | ||
apt-get update -qq && | ||
apt-get install -y --no-install-recommends "$@" | ||
) | ||
CODE=$? | ||
set -e | ||
if [ $CODE -eq 0 ]; then | ||
break | ||
fi | ||
if [ $n -eq $max ]; then | ||
exit $CODE | ||
fi | ||
echo "apt failed, retrying" | ||
n=$(($n + 1)) | ||
done | ||
apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives |