Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API_KEY environment variable not working in Docker image due to outdated build - Suggest adding GitHub Actions for automated releases #166

Open
Maralai opened this issue Nov 28, 2024 · 2 comments

Comments

@Maralai
Copy link

Maralai commented Nov 28, 2024

I have deployed this service as:

faster-whisper:
    image: fedirz/faster-whisper-server:latest-cuda
    container_name: faster-whisper
    restart: unless-stopped
    env_file: /path/to/your/.env
    volumes:
      - /path/to/your/cache:/root/.cache/huggingface
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    networks:
      traefik_network:
        ipv4_address: 172.x.x.x
    labels:
      - "traefik.enable=true"
      # Playground router
      - "traefik.http.routers.whisper-ui.rule=Host(`your-domain.example`) && PathPrefix(`/`)"
      - "traefik.http.routers.whisper-ui.entrypoints=websecure"
      - "traefik.http.routers.whisper-ui.tls.certresolver=myresolver"
      - "traefik.http.routers.whisper-ui.middlewares=bouncer@docker,security@docker,ipallowlist@docker"
      # API router
      - "traefik.http.routers.whisper-api.rule=Host(`your-domain.example`) && PathPrefix(`/v1`)"
      - "traefik.http.routers.whisper-api.entrypoints=websecure"
      - "traefik.http.routers.whisper-api.tls.certresolver=myresolver"
      - "traefik.http.routers.whisper-api.middlewares=bouncer@docker,security@docker"
      # IP allowlist middleware
      - "traefik.http.middlewares.ipallowlist.ipallowlist.sourcerange=10.0.0.0/24"
      # Service
      - "traefik.http.services.whisper.loadbalancer.server.port=8000"
# API Configuration
API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LOG_LEVEL=debug
OPENAI_API_KEY="xxxxxxxxxxxxx"
OPENAI_BASE_URL=http://0.0.0.0:8000/v1/

# Server Settings
UVICORN_HOST=0.0.0.0
UVICORN_PORT=8000

# CORS Settings
ALLOW_ORIGINS='["https://your-domain.example"]'

# UI Settings
ENABLE_UI=true

# Whisper Model Configuration
WHISPER__MODEL=organization/model-name-v3
WHISPER__INFERENCE_DEVICE=cuda
WHISPER__DEVICE_INDEX=[0,1]
WHISPER__COMPUTE_TYPE=float16
WHISPER__CPU_THREADS=8
WHISPER__NUM_WORKERS=4
WHISPER__TTL=600

# Language Settings
DEFAULT_LANGUAGE=en
DEFAULT_RESPONSE_FORMAT=json

# Model Preloading
PRELOAD_MODELS='["organization/model-name-v3"]'

# Performance-Optimized Timing Settings
MAX_NO_DATA_SECONDS=1.5
MIN_DURATION=0.8
WORD_TIMESTAMP_ERROR_MARGIN=0.15
MAX_INACTIVITY_SECONDS=3.0
INACTIVITY_WINDOW_SECONDS=6.0

Which is working well. I noticed that the API_KEY environment variable is not being respected or used. After inspecting the container's source, I noticed that the Docker Hub images need to be updated with the latest commits. This means that important changes, like the API_KEY functionality from c6b0d43, aren't available in the published Docker images.

To solve this and improve the experience in deployment, I'd suggest adding a GitHub Actions workflow to automatically build and publish Docker images on new releases. Here's a proposed workflow file:

name: Build and Push Docker Images

on:
  release:
    types: [published]
  workflow_dispatch:

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Build and push CPU image
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: |
            fedirz/faster-whisper-server:latest
            fedirz/faster-whisper-server:${{ github.event.release.tag_name }}

      - name: Build and push CUDA image
        uses: docker/build-push-action@v5
        with:
          context: .
          file: Dockerfile.cuda
          push: true
          tags: |
            fedirz/faster-whisper-server:latest-cuda
            fedirz/faster-whisper-server:${{ github.event.release.tag_name }}-cuda

This workflow would:

  1. Automatically trigger when a new release is created
  2. Build both CPU and CUDA versions of the image
  3. Tag them with both latest and the release version
  4. Push them to Docker Hub

To implement this, you would need to:

  1. Add this file as .github/workflows/docker-publish.yml
  2. Set up DOCKERHUB_USERNAME and DOCKERHUB_TOKEN secrets in the repository settings
  3. Create a new release to trigger the workflow

This would ensure that users always have access to the latest features and fixes when using the Docker images.

@Maralai Maralai changed the title Security Issue with Docker Security Issue with Docker (open API) Nov 28, 2024
@Maralai Maralai changed the title Security Issue with Docker (open API) API_KEY environment variable not working in Docker image due to outdated build - Suggest adding GitHub Actions for automated releases Nov 28, 2024
@Dimmas
Copy link

Dimmas commented Dec 2, 2024

Please update the whisper server image in hub.docker.com . The image that is there does not support working with API_KEY. The new image is needed for deployment in runpod.io . Thank you.

@Maralai
Copy link
Author

Maralai commented Dec 2, 2024

@fedirz, could you update this on Docker Hub? I would love to deploy with the latest functionality and keep my containers updated with your latest official releases on docker. Please advise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants