Install in Docker With Compose

If you are using Docker Compose to setup your project, then integration of Tideways can be done with a dedicated container running the Tideways Daemon and all PHP containers send data to this single container.

For following docker-composer.yml example, contains only the entries for php (rudimentary) and tideways-daemon container:

version: '3.7'

services:
  php:
    build:
      context: ./php
    expose:
      - 9000
    links:
      - tideways-daemon
    env_file:
      - ./php/.env

 tideways-daemon:
    build:
      context: ./tideways-daemon
If you integrate Tideways in your existing Docker Compose setup, a common mistake is to forget linking tideways-daemon and PHP containers, so that they can communicate over the network.

Tideways-Daemon Dockerized

First, create a sub-folder for the tideways daemon including a Dockerfile with the following contents:

With our example docker-compose.yml this would be ./tideways-daemon/Dockerfile

FROM debian:stable-slim

ARG TIDEWAYS_ENVIRONMENT_DEFAULT=production
ARG DEBIAN_FRONTEND=noninteractive

ENV TIDEWAYS_ENVIRONMENT=$TIDEWAYS_ENVIRONMENT_DEFAULT

RUN useradd --system tideways && \
    apt-get update -yq && \
    apt-get install -yq --no-install-recommends gpg wget ca-certificates && \
    echo 'deb [signed-by=/usr/share/keyrings/tideways.gpg] https://packages.tideways.com/apt-packages-main any-version main' | tee /etc/apt/sources.list.d/tideways.list && \
    wget -qO - 'https://packages.tideways.com/key.gpg' | gpg --dearmor > /usr/share/keyrings/tideways.gpg && \
    apt-get update -yq && \
    apt-get install -yq tideways-daemon && \
    apt-get clean -yq

EXPOSE 9135

USER tideways

ENTRYPOINT ["tideways-daemon","--hostname=tideways-daemon","--address=0.0.0.0:9135"]

PHP With Tideways Extension Dockerized

Every Docker container running PHP then only requires the Tideways PHP extension to be installed and a small change to the INI configuration to point to the Daemon’s container instead of a local socket (which is the default):

tideways.connection="tcp://tideways-daemon:9135"

If you want to use Tideways inside a Docker container, then you are probably building a container already that adds all the extensions you need and modifies the INI configuration according to your needs. This container  Dockerfile needs additional setup instructions to get Tideways running.

This example is based on the php:8.1-fpm image on Docker Hub, if you are using other base images you may need to adjust the installation:

With our example docker-compose.yml this would be ./php/Dockerfile

FROM php:8.1-fpm

ENV TIDEWAYS_APIKEY=<YOUR_APIKEY>
ENV TIDEWAYS_SERVICE=app
ENV TIDEWAYS_SAMPLERATE=25
ENV TIDEWAYS_CONNECTION=tcp://tideways-daemon:9135

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -yq && \
    apt-get install -yq --no-install-recommends gpg wget ca-certificates && \
    echo 'deb [signed-by=/usr/share/keyrings/tideways.gpg] https://packages.tideways.com/apt-packages-main any-version main' | tee /etc/apt/sources.list.d/tideways.list && \
    wget -qO - 'https://packages.tideways.com/key.gpg' | gpg --dearmor > /usr/share/keyrings/tideways.gpg && \
    apt-get update -yq && \
    apt-get install -yq tideways-php && \
    apt-get clean -yq

To pass your API key you can either edit the Dockerfile or create ./php/.env and add the environment variable as follows

TIDEWAYS_APIKEY=<YOUR_APIKEY>

The PHP container now sends all data to the Tideways Daemon container for further processing before its send to our backend.

Still need help? Email [email protected]