Getting Started

Last updated


This page covers the environment go-image-server needs, the two ways to install it, and your first upload and read.

Prerequisites


ItemRequirementSource
Docker Compose deploymentDocker and Docker Composedocker-compose.yaml
Building from sourceGo 1.21+ (the container uses golang:1.22-alpine)app/go.mod
Image processinglibvips with pkg-config; AVIF output needs libheif / libavifapk add in docker-compose.yaml
404 placeholdersapp/internal/assets/image/404-light.svg and 404-dark.svgconfigs.Get404SVG()

The 404 placeholders are not in the repo: the **/image/ rule in .gitignore excludes app/internal/assets/image/, so provide both files before deploying, otherwise failed reads cannot return a placeholder.

Run with Docker Compose


  1. git clone https://github.com/pardnchiu/go-image-server.git
  2. cd go-image-server
  3. docker compose up -d

ServiceImagePublic portNotes
nginxnginx:stable-alpine8080 → 80Mounts ./config/nginx, writes logs to ./logs/nginx
golanggolang:1.22-alpineNoneInstalls libvips at startup, then runs go build -o main ./cmd/server && ./main

Image data is mounted from ./image in the project root to storage/image in the container.

Build from Source


  1. git clone https://github.com/pardnchiu/go-image-server.git
  2. cd go-image-server/app
  3. go build -o main ./cmd/server
  4. ./main

Every storage path resolves against os.Getwd(), so run the binary from app/; otherwise storage/image and the placeholders land in the wrong place. The service listens on 8080 by default; override it with PORT (see Configuration).

First Upload and Read


  1. # Upload into storage/image/upload/blog
  2. curl -X POST -F "filepath=@./photo.jpg" http://localhost:8080/upload/blog
  3. # Read it back via the src in the response; WebP by default
  4. curl -o photo.webp "http://localhost:8080/c/img/blog/<filename>"
  5. # Health check
  6. curl http://localhost:8080/check/state

See Upload API for the response format and Image Parameters for read options.
中文