From c98a532e9807400e7afa3c46947bec3a514cf947 Mon Sep 17 00:00:00 2001 From: Eugene Dorfman Date: Tue, 27 Aug 2024 17:15:54 +0200 Subject: [PATCH] doc compile and runtime dependencies applicable to modules shipping native code --- Dockerfile | 6 ++++++ README.md | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/Dockerfile b/Dockerfile index e0ab26c303c..2838ba17e3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,9 +11,13 @@ WORKDIR /app/prebid-server/ ENV GOROOT=/usr/local/go ENV PATH=$GOROOT/bin:$PATH ENV GOPROXY="https://proxy.golang.org" + +# Installing gcc as cgo uses it to build native code of some modules RUN apt-get update && \ apt-get install -y git gcc && \ apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# CGO must be enabled because some modules depend on native C code ENV CGO_ENABLED 1 COPY ./ ./ RUN go mod tidy @@ -30,6 +34,8 @@ RUN chmod a+xr prebid-server COPY static static/ COPY stored_requests/data stored_requests/data RUN chmod -R a+r static/ stored_requests/data + +# Installing libatomic1 as it is a runtime dependency for some modules RUN apt-get update && \ apt-get install -y ca-certificates mtr libatomic1 && \ apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/README.md b/README.md index 4a44ecd7c6a..b616594a68a 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,11 @@ or compile a standalone binary using the command: ``` bash go build . ``` +**Note:** if building from source there are a couple dependencies to be aware of: +1. *Compile-time*. Some modules ship native code that requires `cgo` (comes with the `go` compiler) being enabled - by default it is and environment variable `CGO_ENABLED=1` do NOT set it to `0`. +2. *Compile-time*. `cgo` depends on the C-compiler, which usually is `gcc`, but can be changed by setting the value of `CC` env var, f.e. `CC=clang`. On ubuntu `gcc` can be installed via `sudo apt-get install gcc`. +3. *Runtime*. Some modules require `libatomic`. On ubuntu it is installed by running `sudo apt-get install libatomic1`. `libatomic1` is a dependency of `gcc`, so if you are building with `gcc` and running on the same machine, it is likely that `libatomic1` is already installed. + Ensure that you deploy the `/static` directory, as Prebid Server requires those files at startup. ## Developing