When using OSes like Alpine in Docker without init.d (SysVInit or SystemD), you can start the Atatus agent directly from binary file. You can follow the below Dockerfile configuration

Dockerfile

copy
icon/buttons/copy
# Dockerfile
FROM php:7.4-fpm-alpine

RUN apk update && apk add --no-cache

RUN cd ~ \
    && export ATATUS_RELEASE="atatus-infra-agent-3.1.0-linux-musl" \
    && curl -sS "https://s3.amazonaws.com/atatus-artifacts/atatus-infra/downloads/${ATATUS_RELEASE}.tar.gz" | tar xvzf - \
    && cd "${ATATUS_RELEASE}" \
    && ATATUS_LICENSE_KEY="lic_infra_***************" sh install.sh install \
    && cd .. \
    && unset ATATUS_RELEASE


CMD ["sh", "-c", "(/usr/bin/atatus-infra-agent -c /etc/atatus-infra-agent/ -l /var/log/atatus-infra-agent/ &); php-fpm"]

Also, in above file, we used php-fpm as a default process. But you can replace it with your process command.

In Docker, Atatus infra agent won't start automatically. So you have to add the (/usr/bin/atatus-infra-agent -c /etc/atatus-infra-agent/ -l /var/log/atatus-infra-agent/ &) before your process command either in ENTRYPOINT/CMD as follows.

Enable Logs

You can collect logs through infra agent by enabling logs_enabled option. In below Dockerfile, we have added the following

files.yml

Following is the sample log config file to capture the app logs.
You can change the file path under paths field.

# files.yml
logs:
  - type: file
    paths:
      - /home/myapp/app/logs/error.log*
    source: source_name
    service: service_name
    severity: error # debug, info, notice, success, warning, error
  • Set logs_enabled to true.
  • Copy sample files.yml to /etc/atatus-infra-agent/conf.d/files.d/ folder. This file defines from which location/path to collect logs.
# Dockerfile
FROM php:7.4-fpm-alpine

RUN apk update && apk add --no-cache

RUN cd ~ \
    && export ATATUS_RELEASE="atatus-infra-agent-3.1.0-linux-musl" \
    && curl -sS "https://s3.amazonaws.com/atatus-artifacts/atatus-infra/downloads/${ATATUS_RELEASE}.tar.gz" | tar xvzf - \
    && cd "${ATATUS_RELEASE}" \
    && ATATUS_LICENSE_KEY="lic_infra_***************" bash install.sh install \
    && sed -i -e 's/logs_enabled: .*/logs_enabled: true/' /etc/atatus-infra-agent/atatus.yml \
    && cd .. \
    && unset ATATUS_RELEASE

# copy custom log config file
COPY ./files.yml /etc/atatus-infra-agent/conf.d/files.d/

CMD ["sh", "-c", "(/usr/bin/atatus-infra-agent -c /etc/atatus-infra-agent/ -l /var/log/atatus-infra-agent/ &); php-fpm"]