# Development Dockerfile - Server only (no Flutter build, no multiplatform) # Much faster builds for backend development # Stage 1: Build the Go server FROM golang:1.23 AS go_builder # Install build dependencies including audio libraries for malgo RUN apt-get update && apt-get install -y \ bash \ git \ gcc \ libasound2-dev \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy go mod files first for better caching COPY go.mod go.sum ./ RUN go mod download # Copy the Go app source COPY server/ ./server/ # Build the Go application (single platform, no cross-compilation) # CGO_ENABLED=1 for audio libraries like malgo RUN CGO_ENABLED=1 go build -v -o sumika-server ./server # Stage 2: Create the final runtime image using Debian FROM debian:bookworm-slim # Install runtime dependencies RUN apt-get update && apt-get install -y \ ca-certificates \ nodejs \ npm \ python3 \ python3-pip \ python3-venv \ libasound2 \ portaudio19-dev \ ffmpeg \ wget \ libasound2-dev \ libpulse-dev \ libjack-jackd2-dev \ alsa-utils \ pulseaudio-utils \ && ln -s /usr/bin/python3 /usr/bin/python \ && rm -rf /var/lib/apt/lists/* # Create Python virtual environment and install packages # RUN python3 -m venv /opt/venv # ENV PATH="/opt/venv/bin:$PATH" # Install PyTorch with CUDA support first # RUN pip install --no-cache-dir \ # torch \ # torchaudio \ # --index-url https://download.pytorch.org/whl/cu121 # Install other packages RUN pip install --break-system-packages --no-cache-dir \ "numpy<2" \ faster-whisper \ pyaudio \ soundfile \ openwakeword \ librosa \ pydub # Create a non-root user to run the app RUN useradd -m -u 1000 appuser RUN chown -R appuser /usr/local/lib/python3.11/dist-packages/ USER appuser WORKDIR /app # Copy the compiled Go binary from the builder stage COPY --chown=appuser --from=go_builder /app/sumika-server /app/ # Copy server assets (scene images, etc.) from the builder stage where we have the full source COPY --chown=appuser --from=go_builder /app/server/assets /app/assets # Run /app/assets/voice/preload.py RUN python /app/assets/voice/preload.py # Copy device metadata script and install dependencies COPY device-metadata-script/ /app/device-metadata-script/ USER root WORKDIR /app/device-metadata-script RUN npm install --production WORKDIR /app USER appuser # Expose the port the server listens on EXPOSE 8081 # Run the server CMD ["/app/sumika-server"]