This guide provides detailed instructions for using Docker with tstbt. It covers both the server and CLI components, and includes information on working with local files, environment variables, and custom builds.
- Prerequisites
- Running with Docker Compose
- Working with Local Files
- Environment Variables
- Custom Builds
- Note on Whisper Extra
Before you begin, ensure you have the following installed on your system:
- Docker
- Docker Compose
- A
.envfile in the project root with necessary environment variables
To start the server component:
docker-compose up serverThis command will build the Docker image (if not already built) and start the server on port 8000.
To use the CLI component:
docker-compose run --rm cli [command] [arguments]For example, to run the transcribe command:
docker-compose run --rm cli transcribe [source_file/url] [options]When using Docker, the container's filesystem is isolated from your host machine. To access local files, you need to "mount" them into the container using the -v or --volume flag.
For files within your project directory, you can mount the entire project directory:
docker-compose run --rm -v $(pwd):/app cli transcribe /app/test/testAssets/audio.mp3 [options]This command:
- Mounts the current directory (
$(pwd)) to/appin the container. - Allows access to any file in your project directory.
- In this example, it transcribes the file at
/test/testAssets/audio.mp3relative to your project root.
For files outside your project directory, provide the full path:
docker-compose run --rm -v /path/to/external/directory:/external cli transcribe /external/audio.mp3 [options]This command:
- Mounts
/path/to/external/directoryfrom your host to/externalin the container. - Allows access to files in that specific external directory.
You can use multiple -v flags to mount several directories:
docker-compose run --rm -v $(pwd):/app -v /path/to/external/directory:/external cli transcribe /external/audio.mp3 [options]This mounts both your project directory and an external directory.
- Paths before the colon (
:) are on your host machine; paths after are in the container. - Use absolute paths for directories outside your project.
- Be cautious when mounting directories to avoid exposing sensitive data.
- The working directory inside the container is set to
/appin the Dockerfile, so paths are relative to that unless you specify absolute paths.
Both the server and CLI services use the .env file specified in the docker-compose.yml. Ensure this file contains all necessary variables for both components.
If you need to set or override environment variables for a specific run, you can use the -e flag:
docker-compose run --rm -e TRANSCRIPTION_SERVER_URL=http://host.docker.internal:8000 cli [command] [arguments]If you need to modify the Docker setup:
- Edit the
Dockerfileordocker-compose.ymlas needed. - Rebuild the services:
docker-compose build
The default Docker setup does not include the Whisper extra. If you need Whisper for transcription:
- Modify the
Dockerfileto install Whisper. - Rebuild the Docker image:
docker-compose build
Remember to adjust paths and environment variables as needed for your specific setup.