Skip to content

Commit eca996f

Browse files
committed
ci: add hello-nginx to ci
1 parent 32bb385 commit eca996f

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,23 @@ jobs:
6161
- name: Stop hello-haproxy container
6262
run: |
6363
docker stop hello-haproxy
64+
65+
hello-nginx:
66+
runs-on: ubuntu-latest
67+
env:
68+
LD_SDK_KEY: "foo"
69+
steps:
70+
- uses: actions/checkout@v4
71+
- name: Build hello-nginx image
72+
run: |
73+
docker build -t launchdarkly:hello-nginx -f ./examples/hello-nginx/Dockerfile .
74+
- name: Run hello-nginx container in background
75+
run: |
76+
docker run -dit --rm --name hello-nginx -p 8123:80 --env LD_SDK_KEY="$LD_SDK_KEY" launchdarkly:hello-nginx
77+
- name: Evaluate feature flag
78+
run: |
79+
curl --retry 5 --retry-all-errors --retry-delay 1 -s -v http://localhost:8123 | tee response.txt
80+
grep -F "Feature flag is false for this user" response.txt || (echo "Expected false evaluation!" && exit 1)
81+
- name: Stop hello-nginx container
82+
run: |
83+
docker stop hello-nginx

examples/hello-nginx/Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM openresty/openresty:jammy
2+
3+
# {{ x-release-please-start-version }}
4+
ARG VERSION=2.0.6
5+
# {{ x-release-please-end }}
6+
7+
RUN apt-get update && apt-get install -y \
8+
curl apt-transport-https ca-certificates \
9+
software-properties-common
10+
11+
RUN add-apt-repository ppa:mhier/libboost-latest && \
12+
apt-get update && \
13+
apt-get install -y boost1.81
14+
15+
RUN curl https://github.com/launchdarkly/cpp-sdks/releases/download/launchdarkly-cpp-server-v3.3.1/linux-gcc-x64-dynamic.zip -L -o /tmp/sdk.zip && \
16+
mkdir ./cpp-sdk && \
17+
unzip /tmp/sdk.zip -d ./cpp-sdk && \
18+
rm /tmp/sdk.zip
19+
20+
RUN mkdir -p /usr/local/openresty/nginx/scripts
21+
22+
COPY . .
23+
COPY ./examples/hello-nginx/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
24+
COPY ./examples/hello-nginx/shared.lua /usr/local/openresty/nginx/scripts/
25+
26+
RUN luarocks make launchdarkly-server-sdk-"${VERSION}"-0.rockspec LD_DIR=./cpp-sdk/build-dynamic/release && \
27+
cp launchdarkly_server_sdk.so /usr/local/openresty/lualib/
28+
29+
# The strategy for this Docker example is to download the C++ SDK release artifacts and use those instead of compiling
30+
# from source. This is for example/CI purposes only; generally it's better to build from source to ensure all libraries
31+
# are compatible.
32+
#
33+
# Since we require a newer version of boost than is available in Ubuntu 22.04, we grab it from a PPA (mhier/libboost-latest).
34+
#
35+
# The SDK dynamic libs expect the boost libs to follow a specific naming convention, which isn't what
36+
# the libraries from the PPA follow ('-mt' suffix is added to indicate the libraries are built with multithreading support enabled.)
37+
#
38+
# It's not 100% clear if these libraries are multithread enabled (build logs in the PPA seem to indicate it),
39+
# but even so, the C++ SDK is single-threaded.
40+
#
41+
# To workaround, add symlinks with the expected names.
42+
RUN cd /usr/lib/x86_64-linux-gnu && \
43+
ln -s libboost_json.so.1.81.0 libboost_json-mt-x64.so.1.81.0 && \
44+
ln -s libboost_url.so.1.81.0 libboost_url-mt-x64.so.1.81.0

0 commit comments

Comments
 (0)