diff --git a/docs/install-agent.md b/docs/install-agent.md index eef64ac062848435c27e59c2a4a168a638631538..3c4cc2aabdd753ced9402bdf740d3c87f5508fa5 100644 --- a/docs/install-agent.md +++ b/docs/install-agent.md @@ -1,12 +1,17 @@ +# Install SkyWalking PHP Agent + +## Requirements When building directly from Git sources or after custom modifications you might also need: * php 7+ * golang 1.13 * SkyWalking Collector +## PHP extension + Agent +The collect data from your instance you need both the PHP extension, and the agent. +No pre built binaries or PHP extension are availble at the moment, so you need to +build them from source. -# Install SkyWalking PHP Agent - -You can run the following command to install the SkyWalking PHP Agent in your computer. +You can run the following commands to install the SkyWalking PHP Agent. ## Install PHP Extension ```shell script @@ -15,11 +20,10 @@ cd SkyAPM-php-sdk phpize && ./configure && make && make install ``` -## Install sky-php-agent (download or build) -### Download sky-php-agent -Go to [release](https://github.com/SkyAPM/SkyAPM-php-sdk/releases) page to download the sky-php-agent required by your platform. Currently there are Linux (amd64, arm64) and Mac versions. - +## Install sky-php-agent ### Build +For installing the sky-php-agent, you first need to build it: + ```shell script cd SkyAPM-php-sdk go build -o sky-php-agent agent/cmd/main.go @@ -52,4 +56,24 @@ skywalking.app_code = MyProjectName sky-php-agent --grpc 127.0.0.1:11800 ``` -### ⚠️⚠️⚠️ Warning *Make sure PHP has read and write permissions on the socks file* \ No newline at end of file +### ⚠️⚠️⚠️ Warning *Make sure PHP has read and write permissions on the socks file* + +## Dockerfile + +### Multi stage build example (starting point) +```bash +FROM golang:1.13 AS builder +ARG SKY_AGENT_VERSION=3.2.6 +WORKDIR /go/src/app +RUN wget https://github.com/SkyAPM/SkyAPM-php-sdk/archive/${SKY_AGENT_VERSION}.tar.gz; \ + tar xvf ${SKY_AGENT_VERSION}.tar.gz +RUN mv SkyAPM-php-sdk-${SKY_AGENT_VERSION} build +RUN cd build; \ + GOOS=linux GOARCH=amd64 go build -o sky-php-agent-linux-x64 ./agent/cmd/main.go + +FROM php:7.2.28-fpm-alpine3.11 +# Copy from builder +COPY --from=builder /go/src/app/build/sky-php-agent-linux-x64 /usr/local/bin/sky-php-agent +RUN apk update && apk upgrade && apk add --no-cache autoconf libc6-compat libcurl curl-dev icu-dev & \ + apk add --no-cache --virtual .build-deps $PHPIZE_DEPS +```