Simple Golang dockerized echo server
The purpose of this server is to allow easy debugging, especially in the cloud. The server sets the HTTP server on all specified addresses. The handler just prints all the request information it gets, e.g.:
GET / HTTP/1.1
Host: localhost:12312
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5
Connection: keep-alive
Dnt: 1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0
Check orian/echoserver on DockerHub
docker run --rm -p 8080:8080 orian/echoserver
The configuration is done through environmental variables:
LISTEN_ADDRis a comma separated list of addresses:localhost:8080,:8081, default value is:80,:8080METRICS_PATHexposes a Prometheus metrics for HTTP server, default is/metrics
If one wants to test the Postgres connection the config should be passed though:
DB_ADDRhostname of databaseDB_PORTport the database listens at, default is5432DB_DATABASEdatabase nameDB_USERPostgres usernameDB_PASSWORDa given user's password
SSL mode is configured through:
DB_SSL_MODEpicks a sslmode, default isdisabled, only if the mode is one ofallow,require,prefer,verify-ca,verify-fullthe SSL will be used.DB_SSL_CERTclient certificate file.DB_SSL_KEYclient key file.DB_SSL_ROOT_CERTserver root certificate.
Kubernetes preStop hook:
PRE_STOP_ADDRan address to register pre stop hook, the handler is available under/k8s/preStop. It gracefully stops the binary.