DataDog / datadog-agent

Main repository for Datadog Agent
https://docs.datadoghq.com/
Apache License 2.0
2.74k stars 1.17k forks source link

serverless-init - better handling of non executable command #27083

Open piotrekkr opened 1 week ago

piotrekkr commented 1 week ago

Currently it is really hard to debug issues if Datadog serverless-init is used and there is some typo or command that should be run does not exist or is not executable. Here is example dockerfile:

# syntax=docker/dockerfile:1
FROM php:8.2.12-fpm-bookworm

COPY --from=datadog/serverless-init:1 /datadog-init /app/datadog-init

ADD https://github.com/DataDog/dd-trace-php/releases/latest/download/datadog-setup.php /datadog-setup.php

RUN php /datadog-setup.php --php-bin=all --enable-profiling

ENV DD_VERSION=test
ENV DD_LOGS_ENABLED=true
ENV DD_TRACE_ENABLED=true
ENV DD_TRACE_PROPAGATION_STYLE=datadog
ENV DD_APM_ENABLED=true
ENV DD_SERVICE=my-service
ENV DD_SITE=datadoghq.eu
ENV DD_DOGSTATSD_PORT=8125

ENTRYPOINT ["/app/datadog-init"]

CMD ["/usr/local/sbin/php-fm"]

CMD contains a typo and when running this container there is no error message, container just exit with error code.

$ docker build -f Dockerfile . -t dd-exit:test
....

$ docker run -it --rm -e DD_API_KEY="key"  -e DD_ENV=test --name=dd-exit dd-exit:test

$

This is far from optimal DX and pretty hard to debug if pushed to the cloud. Would it be possible for serverless-init to check first if command from CMD exist and is executable? If not then exit with some meaningful error message?

Thank you.

juanpabloinformatica commented 1 week ago

Hello, can u assing that issue to me??