diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3cbdd402..6e7578da 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,6 +15,13 @@ jobs: permissions: contents: read packages: write + strategy: + matrix: + include: + - image: "${{ github.repository }}" + dockerfile: "Dockerfile.modelserver" + - image: "${{ github.repository }}-worker" + dockerfile: "Dockerfile.workerserver" steps: - name: Checkout repository @@ -37,14 +44,14 @@ jobs: id: meta uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ matrix.image }} - name: Build and push Docker image uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 with: context: . push: true + file: ${{ matrix.dockerfile }} platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - diff --git a/Dockerfile b/Dockerfile.modelserver similarity index 86% rename from Dockerfile rename to Dockerfile.modelserver index 03a34e7a..303f83f8 100644 --- a/Dockerfile +++ b/Dockerfile.modelserver @@ -31,10 +31,15 @@ COPY pyproject.toml . COPY poetry.toml . COPY poetry.lock . COPY modelserver/ ./modelserver +COPY workerproto/ ./workerproto COPY --from=build-frontend /app/dist/ ./frontend/dist RUN pip install poetry RUN poetry install --without=dev,remoteworker +# Standard HTTP interface for API/asset traffic EXPOSE 8000 + +# gRPC interface for workers +EXPOSE 8001 CMD ["./.venv/bin/modelserver"] diff --git a/Dockerfile.workerserver b/Dockerfile.workerserver new file mode 100644 index 00000000..8afeb16d --- /dev/null +++ b/Dockerfile.workerserver @@ -0,0 +1,42 @@ +# syntax=docker/dockerfile:1 + +FROM node:18.16.0-alpine3.18 AS build-frontend + +RUN mkdir /app +COPY frontend/ /app +WORKDIR /app + +RUN npm install && npm run build + + +FROM python:3.11.5-slim-bullseye +LABEL authors="intrinsiclabsai" + +# For cleanliness +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONBUFFERED 1 + +# Add build packages +RUN apt update \ + && apt install -y build-essential cmake \ + && rm -rf /var/lib/apt /var/lib/dpkg /var/lib/cache /var/lib/log + +# Start server +RUN mkdir /app +RUN mkdir /app/frontend + +WORKDIR /app +COPY README.md . +COPY pyproject.toml . +COPY poetry.toml . +COPY poetry.lock . +COPY modelserver/ ./modelserver +COPY workerproto/ ./workerproto +COPY workerserver/ ./workerserver +COPY --from=build-frontend /app/dist/ ./frontend/dist + +RUN pip install poetry +RUN poetry install --without=dev + +EXPOSE 8000 +CMD ["./.venv/bin/workerserver"]