Skip to content

Commit

Permalink
build separate images for server/worker (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y authored Nov 15, 2023
1 parent a72fede commit d96adef
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}

5 changes: 5 additions & 0 deletions Dockerfile → Dockerfile.modelserver
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
42 changes: 42 additions & 0 deletions Dockerfile.workerserver
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit d96adef

Please sign in to comment.