juanmc2005 / diart

A python package to build AI-powered real-time audio applications

Home Page:https://diart.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create a Docker image

juanmc2005 opened this issue · comments

Problem

Setting up the project is a bit too long with all the dependencies and the use of conda.

Idea

Create and publish docker images with new diart versions, allowing quick setup and deployment

I just wrote a really small dockerfile for internal usage but it might be feasible here too

ARG _BASE=debian:bookworm
FROM $_BASE as builder

COPY src /code/src
COPY setup.cfg setup.py requirements.txt pyproject.toml /code/

RUN apt-get update && apt-get install -y --no-install-recommends \
    python3-pip \
    python3-setuptools \
    python3-wheel \
    python3-dev \
    python3-venv \
    build-essential

RUN python3 -m venv /opt/venv
ARG PATH="/opt/venv/bin:$PATH"
ENV PATH="/opt/venv/bin:$PATH"

RUN pip3 install /code

FROM $_BASE

# Runtime deps
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 \
    python3-venv \
    libportaudio2 \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

# Get venv from builder
ARG PATH="/opt/venv/bin:$PATH"
ENV PATH="/opt/venv/bin:$PATH"
COPY --from=builder /opt/venv /opt/venv

thanks @sorgfresser ! I think you could simplify that by using python:3.10-bookworm. Also, no need to use venv, right?

I just wrote a really small dockerfile for internal usage but it might be feasible here too

ARG _BASE=debian:bookworm
FROM $_BASE as builder

COPY src /code/src
COPY setup.cfg setup.py requirements.txt pyproject.toml /code/

RUN apt-get update && apt-get install -y --no-install-recommends \
    python3-pip \
    python3-setuptools \
    python3-wheel \
    python3-dev \
    python3-venv \
    build-essential

RUN python3 -m venv /opt/venv
ARG PATH="/opt/venv/bin:$PATH"
ENV PATH="/opt/venv/bin:$PATH"

RUN pip3 install /code

FROM $_BASE

# Runtime deps
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 \
    python3-venv \
    libportaudio2 \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

# Get venv from builder
ARG PATH="/opt/venv/bin:$PATH"
ENV PATH="/opt/venv/bin:$PATH"
COPY --from=builder /opt/venv /opt/venv

I got some problem with ffmpeg<4.4, how to correctly install it in docker?

commented

Would be so great to have a docker image instead of using conda and to avoid having several version bugs between environment & requirement.