Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 1.39 KB

README.md

File metadata and controls

44 lines (35 loc) · 1.39 KB

ruby-docker-skeleton

This repo contains a skeleton for creating an app that can run in both Docker, Podman and in the shell.

The skeleton also pulls in a Prometheus that can be used to expose metrics for Kubernetes. Note that the automatic exporter is disabled, because I think it adds to much rubble, feel free to enable it.

Docker

Build

docker build -t ruby-docker-skeleton .

Run

docker run --rm --publish=8080:8080 ruby-docker-skeleton

Podman

Podman works almsot just like Docker, but you can run it in userspace!

Build

podman build -t ruby-docker-skeleton .

Run

podman run --rm --publish=8080:8080 ruby-docker-skeleton

Signals

In the Dockerfile there is one line that changes what signal the app respons to.

# Send "ctrl-c"-like signal when stopping
STOPSIGNAL SIGINT

This is also handled in config.ru

trap "SIGTERM" do Process.kill("SIGINT", 0) end

This is because some Cloud-provides ignore the STOPSIGNAL in the Dockerfile

Metrics

Metrics is collected with Prometheus::Middleware. This gem can automatically collect data, but this it turned off by in this application.

#use Prometheus::Middleware::Collector # This adds automatic metrics for endpoints

You can still push your own metrics when you feel like it.

@@requests_total.increment(labels: { endpoint: "/ping" })