Sign inSign up

qmcgaw/srv

By qmcgaw

Updated about 5 years ago

SHORT_DESCRIPTION

Image
0

2.7K

qmcgaw/srv repository overview

SRV

srv is a small Go application to use as a container or as a base Docker image in other projects to serve static files over HTTP

Build status Docker Pulls Docker Stars Image size Image version

Join Slack channel GitHub last commit GitHub commit activity GitHub issues

Features

  • Compatible with amd64, 386, arm64, arm32v7, arm32v6, ppc64le, s390x and riscv64 CPU architectures
  • Runs without root as user ID 1000
  • Based on the scratch docker image for a tiny size of 9.11MB (uncompressed amd64 image)
  • Docker image tags and sizes
  • Prometheus metrics available on :9091

Setup

As a container

We assume your static files are at /yourpath on your host.

  1. Ensure the ownership of your static files matches the ones from the container:

    chown -R 1000 /yourpath
    
  2. Run the container, bind mounting /yourpath to /srv as ready only:

    docker run -d -p 8000:8000/tcp -v /yourpath:/srv:ro qmcgaw/srv
    

    You can also use docker-compose.yml with:

    docker-compose up -d
    
  3. You can update the image with docker pull qmcgaw/srv or use one of the tags available

As a base image

You can use it in your own project with:

FROM qmcgaw/srv
COPY --chown=1000 srv /srv

Or with a multi stage Dockerfile:

FROM someimage AS staticbuilder
COPY . .
RUN somecompiler --output-to=/tmp/build

FROM qmcgaw/srv
COPY --from=staticbuilder --chown=1000 /tmp/build /srv
Environment variables
Environment variableDefaultPossible valuesDescription
HTTP_SERVER_ADDRESS:8000Valid addressHTTP server listening address
HTTP_SERVER_ROOT_URL/URL pathHTTP server root URL
HTTP_SERVER_LOG_REQUESTSonon or offLog requests and responses information
FILEPATH_SRV/srvValid file pathFile path to your static files directory
METRICS_SERVER_ADDRESS:9090Valid addressPrometheus HTTP server listening address
LOG_LEVELinfodebug, info, warning, errorLogging level
HEALTH_SERVER_ADDRESS127.0.0.1:9999Valid addressHealth server listening address
TZAmerica/MontrealstringTimezone

Development

  1. Setup your environment

    Using VSCode and Docker (easier)

    1. Install Docker
      • On Windows, share a drive with Docker Desktop and have the project on that partition
      • On OSX, share your project directory with Docker Desktop
    2. With Visual Studio Code, install the remote containers extension
    3. In Visual Studio Code, press on F1 and select Remote-Containers: Open Folder in Container...
    4. Your dev environment is ready to go!... and it's running in a container :+1: So you can discard it and update it easily!

    Locally

    1. Install Go, Docker and Git

    2. Install Go dependencies with

      go mod download
      
    3. Install golangci-lint

    4. You might want to use an editor such as Visual Studio Code with the Go extension. Working settings are already in .vscode/settings.json.

  2. Commands available:

    # Build the binary
    go build cmd/app/main.go
    # Test the code
    go test ./...
    # Lint the code
    golangci-lint run
    # Build the Docker image
    docker build -t qmcgaw/srv .
    
  3. See Contributing for more information on how to contribute to this repository.

License

This repository is under an MIT license unless otherwise indicated

Tag summary

Content type

Image

Digest

Size

3.2 MB

Last updated

about 5 years ago

docker pull qmcgaw/srv