Install in Docker
Tideways-Daemon Container
We provide a pre-built Docker image to pull into your project.
-
Pull the image:
docker pull ghcr.io/tideways/daemon
-
Start the container:
docker run -d --name=tideways-daemon ghcr.io/tideways/daemon
Looking at the output:
$ docker logs tideways-daemon 2024/03/14 09:15:50 maxprocs: Leaving GOMAXPROCS=12: CPU quota undefined [tideways-daemon] 2024/03/14 09:15:50 Starting up daemon (version 1.8.42) [tideways-daemon] 2024/03/14 09:15:50 Sending to https://ingest.tideways.io [tideways-daemon] 2024/03/14 09:15:50 Collecting for tideways-daemon#96a2d513ef61 [tideways-daemon] 2024/03/14 09:15:50 Listening for TCP connections on [::]:9135.
We see the daemon properly starting, using tideways-daemon as the default
hostname and listening on [::]:9135
(which will implicitly listen on IPv4’s
0.0.0.0
as well).
The Tideways Daemon does not perform authentication, thus it is necessary to set up proper network or firewall rules that the container cannot be reached from public. |
You can pass all configuration flags directly to docker run
, for example the
environment and hostname flags:
$ docker run -d --name=tideways-staging-daemon ghcr.io/tideways/daemon --env=staging --hostname=tideways-staging-daemon
To update to the latest version of the tideways-daemon you have to pull the image again and rebuild the container. |
The next step is now pointing the PHP container towards the tideways-daemon-container.
Installing Tideways Extension in a Docker PHP Container
A Docker container running PHP then requires the Tideways PHP extension to be installed and a small change to the configuration to point to the Daemon’s container instead of a local socket (which is the default).
Here is an example based on how to install the Tideways PHP extension with
the php:8.3-fpm
image from Docker Hub, if you are using other base images you
may need to adjust the installation:
FROM php:8.3-fpm
ENV TIDEWAYS_APIKEY=<YOUR_APIKEY>
ENV TIDEWAYS_SERVICE=app
ENV TIDEWAYS_SAMPLERATE=25
ENV TIDEWAYS_CONNECTION=tcp://tideways-daemon:9135
# Use `ghcr.io/tideways/php:alpine` when using an alpine-based PHP image.
COPY --from=ghcr.io/tideways/php:latest /tideways/ /tideways/
RUN docker-php-ext-enable --ini-name tideways.ini "$(php /tideways/get-ext-path.php)"
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>
You can also change the other extension related environment variables.
-
TIDEWAYS_SERVICE
declaring the service name -
TIDEWAYS_CONNECTION
with the address of the daemon if it is nottideways-daemon:9135
. -
TIDEWAYS_SAMPLERATE
to reconfigure the sample rate.
The PHP container now sends all data to the Tideways Daemon container for further processing before its send to our backend.
Alpine Containers
When using Alpine Linux, use a slightly modified Dockerfile:
FROM php:8.3-fpm-alpine
ENV TIDEWAYS_APIKEY=<YOUR_APIKEY>
ENV TIDEWAYS_SERVICE=app
ENV TIDEWAYS_SAMPLERATE=25
ENV TIDEWAYS_CONNECTION=tcp://tideways-daemon:9135
COPY --from=ghcr.io/tideways/php:alpine /tideways/ /tideways/
RUN docker-php-ext-enable --ini-name tideways.ini "$(php /tideways/get-ext-path.php)"
With docker-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. The php/
folder contains the
Dockerfile from the documentation above.
services:
php:
build:
context: ./php
links:
- tideways-daemon
env_file:
- ./php/.env
tideways-daemon:
image: ghcr.io/tideways/daemon
command: "--env=production" # Modify environment and add any other daemon parameters here
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. |