Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP SDK Relay Server #62

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b54d139
PHP testing app
typotter Aug 30, 2024
2318f6f
script to build and launch using a ref of the SDK
typotter Aug 30, 2024
8a74a71
poller and some Docker
typotter Aug 30, 2024
6f0f00f
other types
typotter Aug 30, 2024
205d96b
handling env vars and running in docker
typotter Aug 30, 2024
dfdaa70
notes
typotter Sep 3, 2024
6523ee5
WIP
typotter Sep 3, 2024
1650299
wip
typotter Sep 3, 2024
489829b
set base dir for php server
typotter Sep 3, 2024
c7f1b67
Dockeration
typotter Sep 6, 2024
8e9a054
safe load .env
typotter Sep 6, 2024
c40ac55
refactor config
typotter Sep 6, 2024
d7989fc
refactor config
typotter Sep 6, 2024
96fe718
hW
typotter Sep 6, 2024
f756863
rocking and rolling
typotter Sep 6, 2024
022d56a
process single test case
typotter Sep 6, 2024
3cdf687
release script
typotter Sep 9, 2024
c0d83a8
encode log entries before transmit
typotter Sep 9, 2024
33b6c53
docker image name change
typotter Sep 9, 2024
9e4c62c
return bandit requst
typotter Sep 9, 2024
eac5f9f
wip
typotter Sep 9, 2024
410274e
debug wip
typotter Sep 9, 2024
dfb632a
fix bandit parsing
typotter Sep 9, 2024
0f2f6ef
env var polish
typotter Sep 9, 2024
6d4dc4b
Rename pkg
typotter Sep 10, 2024
1018479
typo
typotter Sep 10, 2024
cbbab17
api config values
typotter Sep 10, 2024
bb43075
cleanup
typotter Sep 10, 2024
0dd07e1
rename directory
typotter Sep 12, 2024
e91cbff
newlines
typotter Sep 12, 2024
3da231e
comment
typotter Sep 12, 2024
662fa8b
newlines
typotter Sep 12, 2024
8edf5f9
add /sdk/rest path to PHP relay server
typotter Sep 12, 2024
9a82923
docker run fix
typotter Sep 12, 2024
b13ebd4
clarify loggers by name
typotter Sep 13, 2024
4ce3e79
guard clause
typotter Sep 13, 2024
e640bc0
healthcheck
typotter Sep 13, 2024
dad99bf
stop and clear container in run script
typotter Sep 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions package-testing/php-sdk-relay/.env.EXAMPLE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Set your appropriate values and save as `.env`
EPPO_API_HOST=localhost
EPPO_API_PORT=5000
EPPO_API_KEY=A123456780

SDK_RELAY_HOST=localhost
SDK_RELAY_PORT=4000
2 changes: 2 additions & 0 deletions package-testing/php-sdk-relay/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
vendor
32 changes: 32 additions & 0 deletions package-testing/php-sdk-relay/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM php:8.1

# dependencies needed for composer (and for build.sh).
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip


COPY --from=composer /usr/bin/composer /usr/bin/composer

WORKDIR /relayapp

COPY . .

COPY --chmod=755 build.sh /

RUN composer install

ENV SDK_RELAY_HOST=0.0.0.0
ENV EPPO_API_HOST=host.docker.internal

EXPOSE 4000

HEALTHCHECK CMD curl --fail http://localhost:4000 || exit 1


CMD ["/build.sh"]
33 changes: 33 additions & 0 deletions package-testing/php-sdk-relay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# PHP Testing Server

Post test case files to this server and check the results against what's expected.

## Setup
Open `.env.EXAMPLE`, set your favourite configs and then save it as `.env`

## Running

### Locally

```shell
BASH_ENV=.env SDK_REF=<your branch/tag/SHA> ./build.sh
```

### With Docker
#### Build Docker Image
```shell
docker build -t Eppo-exp/php-sdk-relay .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

```

#### Run the docker container
```shell
docker run -p $PHP_TEST_SERVER_PORT:$PHP_TEST_SERVER_PORT -t Eppo-exp/php-sdk-relay --env-file ./.env -e SDK_REF=<your branch/tag/SHA>
```

## Development

### Running locally

```shell
php -S localhost:4000 src/index.php
```
28 changes: 28 additions & 0 deletions package-testing/php-sdk-relay/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

composer install

# Set default values for vars

: "${SDK_REF:=main}"
: "${SDK_RELAY_HOST:=localhost}"
: "${SDK_RELAY_PORT:=4000}"
SDK="https://github.com/Eppo-exp/php-sdk.git"


# checkout the specified ref of the SDK repo, build it, and then insert it into vendors here.
mkdir -p tmp

echo "Cloning ${SDK}@${SDK_REF}"
git clone -b ${SDK_REF} --depth 1 --single-branch ${SDK} tmp

# overwrite vendor files
cp -Rf tmp/. ./vendor/eppo/php-sdk/
rm -Rf tmp

# Run the poller
php src/eppo_poller.php &

echo "Listening on ${SDK_RELAY_HOST}:${SDK_RELAY_PORT}"

php -S "${SDK_RELAY_HOST}:${SDK_RELAY_PORT}" -t src
35 changes: 35 additions & 0 deletions package-testing/php-sdk-relay/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "eppo/php-sdk-test",
"description": "Test server using the PHP SDK",
"type": "project",
"license": "MIT",
"homepage": "https://github.com/Eppo-exp/sdk-test-data",
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Eppo\\SDKTest\\": "src/"
}
},
"authors": [
{
"name": "Ty Potter",
"email": "[email protected]"
}
],
"require": {
"php": "^8.1",
"eppo/php-sdk": "^3.2",
"vlucas/phpdotenv": "^5.6",
"php-http/curl-client": "^2.3",
"nyholm/psr7": "^1.8",
"slim/slim": "^4.14",
"slim/psr7": "^1.7",
"php-di/php-di": "^7.0",
"slim/http": "^1.4"
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
Loading