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

Tideways-Daemon Dockerized

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

FROM debian:stable-slim

ARG TIDEWAYS_ENVIRONMENT_DEFAULT=production
ENV TIDEWAYS_ENVIRONMENT=$TIDEWAYS_ENVIRONMENT_DEFAULT

RUN apt-get update && apt-get install -yq --no-install-recommends gnupg2 curl sudo ca-certificates

RUN echo 'deb http://s3-eu-west-1.amazonaws.com/tideways/packages debian main' > /etc/apt/sources.list.d/tideways.list && \
    curl -sS 'https://s3-eu-west-1.amazonaws.com/tideways/packages/EEB5E8F4.gpg' | apt-key add -
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -yq tideways-daemon && \
    apt-get autoremove --assume-yes && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

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: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:7.2-fpm-stretch image on Docker Hub, if you are using other base images you may need to adjust the installation:

FROM php:7.2-fpm-stretch

RUN echo 'deb http://s3-eu-west-1.amazonaws.com/tideways/packages debian main' > /etc/apt/sources.list.d/tideways.list && \
    curl -sS 'https://s3-eu-west-1.amazonaws.com/tideways/packages/EEB5E8F4.gpg' | apt-key add - && \
    apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get -yq install tideways-php && \
    apt-get autoremove --assume-yes && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN echo 'extension=tideways.so\ntideways.connection=tcp://tideways:9135\ntideways.api_key=${TIDEWAYS_APIKEY}\n' > /usr/local/etc/php/conf.d/40-tideways.ini

Troubleshooting to install the tideways-php extension in php container with different extension-paths could fail with message "No PHP installation found". The installation package search php-extensions-path to move the file "tideways.so" in. It could be fixed with moving it with extra command in Dockerfile.

In the example Dockerfile we create a 40-tideways.ini-file that uses the TIDEWAYS_APIKEY environment variable, so the .env-file have following content:

TIDEWAYS_APIKEY=<YOUR_API_KEY>
TIDEWAYS_SERVICE=web
TIDEWAYS_SAMPLERATE=25

This ENV variables are possible to use:

# Environment Variables
ENV TIDEWAYS_APIKEY <YOUR_API_KEY>
ENV TIDEWAYS_SERVICE web
ENV TIDEWAYS_SAMPLERATE 25
ENV TIDEWAYS_FRAMEWORK <OPTIONAL>

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]