Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sanskarsharma/thumbgen/llms.txt

Use this file to discover all available pages before exploring further.

Thumbgen ships with a production-ready Dockerfile and a docker-compose.yaml so you can containerise the service in a single command. The image is built with a multi-stage pipeline that keeps the final artifact small and self-contained, with ffmpeg bundled in for full video thumbnail support.

How the Dockerfile Works

The build uses two stages:
  1. Builder stage — starts from golang:1.14-alpine, installs the C toolchain (gcc, g++, make, git), downloads Go module dependencies, and compiles a statically-linked binary with size-optimised linker flags (-ldflags="-s -w").
  2. Runtime stage — starts from a clean alpine:3.9 image, installs ffmpeg (bumping the final image to ~65 MB — without ffmpeg it would be ~12 MB), copies in the compiled binary and the public/ frontend directory, and exposes port 4499.
FROM golang:1.14-alpine AS builder
RUN apk --no-cache add gcc g++ make git
WORKDIR /go/src/app
COPY . .

ENV GOOS=linux \
    GOBIN=$GOPATH/bin
RUN go mod download
RUN go build -ldflags="-s -w" -o ./bin/main-bin ./*.go

# creating an alpine image from scratch (lightweight)
FROM alpine:3.9

# adding ffmpeg. used for creation thumbnail from video
# without this, image size : ~12 MB ; with this, image size : ~65 MB
# there are lighter images for ffmpeg, JIC needed : https://hub.docker.com/r/jrottenberg/ffmpeg
RUN apk add --update ffmpeg

# copying binary built from previous stage
WORKDIR /usr/bin
COPY --from=builder /go/src/app/bin /go/bin

# copying public directory with frontend files
COPY --from=builder /go/src/app/public ./public

EXPOSE 4499
ENTRYPOINT /go/bin/main-bin

Running the Container

Build the image and start a detached container with port 4499 mapped to your host:
docker build -t thumbgen:v0 .
docker run -d -p 4499:4499 thumbgen:v0
The service is then available at http://localhost:4499.
You do not need to set ENV=LOCAL when running Thumbgen in Docker. The Alpine-based container has ash available by default, which is exactly what Thumbgen expects. The ENV=LOCAL flag is only needed when running directly on macOS or Linux with go run.
The docker-compose.yaml already sets restart: unless-stopped, which restarts the container automatically after a crash or a host reboot (unless you explicitly stop it with docker-compose down). Change this to restart: always if you want the container to restart even after you manually stop it, or restart: on-failure to only restart on non-zero exit codes.

Build docs developers (and LLMs) love