Skip to content

Commit 8ed25a7

Browse files
committed
enhance dockerized development environment
Add an option to control which PHP version is to be used in devenv service via PHP env var passed at the time when dev-shell is started (or any dev-* target is build).
1 parent 4badb0e commit 8ed25a7

File tree

3 files changed

+48
-24
lines changed

3 files changed

+48
-24
lines changed

Makefile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -475,24 +475,27 @@ test-services-stop:
475475
# Docker Development Environment
476476
#
477477

478-
dev-shell:
479-
docker compose --profile dev up --build --remove-orphans -d
478+
devenv-image:
479+
@docker compose --profile dev build devenv
480+
481+
dev-shell: devenv-image
482+
docker compose --profile dev up --pull --remove-orphans -d
480483
docker compose exec -it devenv bash -c "sh files/set_path.sh ; bash"
481484

482-
dev-build:
483-
docker compose --profile dev up --build --remove-orphans -d
485+
dev-build: devenv-image
486+
docker compose --profile dev up --pull --remove-orphans -d
484487
docker compose exec -it devenv bash -c "sh files/set_path.sh ; make -j4 all"
485488

486-
dev-unit-tests:
487-
docker compose --profile dev up --build --remove-orphans -d
489+
dev-unit-tests: devenv-image
490+
docker compose --profile dev up --pull --remove-orphans -d
488491
docker compose exec -it devenv bash -c "sh files/set_path.sh ; make -j4 valgrind"
489492

490-
dev-integration-tests:
491-
docker compose --profile dev up --build --remove-orphans -d
493+
dev-integration-tests: devenv-image
494+
docker compose --profile dev up --pull --remove-orphans -d
492495
docker compose exec -it devenv bash -c "sh files/set_path.sh ; ./bin/integration_runner -agent ./agent/.libs/newrelic.so"
493496

494-
dev-all:
495-
docker compose --profile dev up --build --remove-orphans -d
497+
dev-all: devenv-image
498+
docker compose --profile dev up --pull --remove-orphans -d
496499
docker compose exec -it devenv bash -c "sh files/set_path.sh ; make -j4 all valgrind; ./bin/integration_runner -agent ./agent/.libs/newrelic.so"
497500

498501
dev-stop:

docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ services:
7575
build:
7676
context: .
7777
dockerfile: files/Dockerfile
78+
args:
79+
PHP_VER: ${PHP:-8.3}
7880
user: ${UID}:${GID}
7981
environment:
8082
MEMCACHE_HOST: memcached

docs/dev_environment.md

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,38 @@ The dockerized development environment prototype allows contributors to both dev
66

77
docker-compose spins up `mysql` and `redis` and other databases in separate containers.
88

9-
Two environment variables to note:
10-
`NEWRELIC_LICENSE_KEY` is required to run the integration tests and should be set to your NR license key.
11-
If your collector isn’t the default (collector.newrelic.com), set the `NEWRELIC_COLLECTOR_HOST` to the appropriate value.
9+
## Prerequisites
1210

13-
PHP_VER can also be set to vary the PHP version being used.
11+
### 1. Docker Compose
1412

15-
Set all environment variables prior to running the development environment.
13+
Dockerized development environment for the New Relic PHP Agent uses following Docker Compose services as a runtime platform. So you need `docker` with `docker compose` installed.
14+
15+
### 2. Environment variables
16+
17+
Dockerized development environment for the New Relic PHP Agent needs a valid license key available in `NEW_RELIC_LICENSE_KEY` environment variable.
18+
This environment variable must be set prior to starting Dockerized development environment for the New Relic PHP Agent. The easiest way to set
19+
`NEW_RELIC_LICENSE_KEY` environment variable is via `.env` file. Simply create `.env` file in the top level directory, and add definition
20+
of `NEW_RELIC_LICENSE_KEY` environment variable there, e.g.:
21+
```
22+
NEW_RELIC_LICENSE_KEY=...
23+
```
24+
25+
The second, optional environment variable, that controls PHP version in Dockerized development environment for the New Relic PHP Agent is `PHP`. `PHP` defaults to latest PHP supported by the agent.
26+
This environment variable can be provided at the time when Dockerized development environment for the New Relic PHP Agent is started, e.g.:
27+
```
28+
make dev-shell PHP=8.2
29+
```
1630

1731
## Options for using the environment
1832

19-
## With a shell environment
33+
### With a shell environment
34+
35+
To start the dev environment type `make dev-shell`. This will spin up `devenv` service in `agent-devenv` container, with:
36+
- latest PHP supported by the agent (this can be overriden with `PHP` environment variable like this: `make dev-shell PHP=8.2`)
37+
- all the tools needed to build the agent
38+
- all the tools needed to run unit tests
39+
- all the tools and supporting services to run integration tests
2040

21-
To start the dev environment type `make dev-shell`. This will create a set of docker containers.
2241
A prompt will open and you’ll be able to compile and run all `make` commands right away with no additional setup (for example: `make -j4 all` or `make -j4 valgrind` or `make -j4 run_tests`).
2342

2443
After compiling the agent, the integration tests can be run using the `integration_runner`.
@@ -31,27 +50,27 @@ To end the session type `exit`. You can run `make dev-stop` to stop the docker-
3150

3251
In the shell, you can run all `make` commands as you normally would.
3352

34-
## Build only
53+
### Build only
3554

3655
`make dev-build`
3756

38-
## Unit Tests only
57+
### Unit Tests only
3958

4059
`make dev-unit tests`
4160

42-
## Integration Tests only
61+
### Integration Tests only
4362

4463
`make dev-integration-tests`
4564

46-
## Build and test all
65+
### Build and test all
4766

4867
`make dev-all`
4968

50-
## Stop all containers
69+
### Stop all containers
5170

5271
`make dev-stop`
5372

54-
# Next steps and issues
73+
## Next steps and issues
5574

56-
## There is possibly some incompatibility with mysql in the main build container as one of the mysql unit tests fails. Unless this is resolved, It might make sense at a future point to have the integration tests run from a different container than the build container.
75+
### There is possibly some incompatibility with mysql in the main build container as one of the mysql unit tests fails. Unless this is resolved, It might make sense at a future point to have the integration tests run from a different container than the build container.
5776

0 commit comments

Comments
 (0)