From 905f461ee8e74f25b3126f8102ba64820d85bd93 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 18 Oct 2025 10:52:58 +0200 Subject: [PATCH] Add basic healthcheck to oauth2-proxy container template using binary version check for distroless compatibility Reference: https://chatgpt.com/share/68f35550-4248-800f-9c6a-dbd49a48592e --- roles/web-app-oauth2-proxy/templates/container.yml.j2 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/roles/web-app-oauth2-proxy/templates/container.yml.j2 b/roles/web-app-oauth2-proxy/templates/container.yml.j2 index e4db085a..4500321c 100644 --- a/roles/web-app-oauth2-proxy/templates/container.yml.j2 +++ b/roles/web-app-oauth2-proxy/templates/container.yml.j2 @@ -1,11 +1,18 @@ {% if applications | get_app_conf(application_id, 'features.oauth2', False) %} oauth2-proxy: - image: quay.io/oauth2-proxy/oauth2-proxy:{{ applications['web-app-oauth2-proxy'].version}} + image: quay.io/oauth2-proxy/oauth2-proxy:{{ applications['web-app-oauth2-proxy'].version }} restart: {{ DOCKER_RESTART_POLICY }} command: --config /oauth2-proxy.cfg + container_name: {{ application_id | get_entity_name }}-oauth2-proxy hostname: oauth2-proxy ports: - 127.0.0.1:{{ ports.localhost.oauth2_proxy[application_id] }}:4180/tcp volumes: - "{{ docker_compose.directories.volumes }}{{ applications | get_app_conf('web-app-oauth2-proxy','configuration_file')}}:/oauth2-proxy.cfg" + healthcheck: + test: ["CMD", "/bin/oauth2-proxy", "--version"] + interval: 30s + timeout: 5s + retries: 1 + start_period: 5s {% endif %} \ No newline at end of file