Skip to content

Commit

Permalink
containerized development environment
Browse files Browse the repository at this point in the history
  • Loading branch information
lavarou committed Dec 27, 2023
1 parent d7f1ef5 commit 067c002
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 0 deletions.
47 changes: 47 additions & 0 deletions build-services.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# PHPs supported by composer build services
PHPS=7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3
SERVICES=go redisdb mysqldb $(addprefix php-,$(PHPS))

# Shell user - default to `root`, can be overriden to `root`
SHELL_USER=root

start:
@test -z $$PULL || docker compose -f build-services.yml pull $(SERVICES)
docker compose -f build-services.yml up --remove-orphans -d $(SERVICES)

stop:
docker compose -f build-services.yml stop

exec:
@test -z $$PHP && { echo "Please provide PHP version with PHP=<VERSION>"; exit 2; } || true
@test -z $$CMD && { echo "Please provide CMD to run with CMD=<target>"; exit 2; } || true
@docker compose -f build-services.yml exec php-${PHP} $(CMD) $(ARGS)

.PHONY: shell
shell:
@test -z $$PHP && { echo "Please provide PHP version with PHP=<VERSION>"; exit 2; } || \
docker compose -f build-services.yml exec --user $(SHELL_USER) -it php-$${PHP} /bin/bash

bin/integration_runner:
docker compose -f build-services.yml exec go make bin/integration_runner

build-integration-runner: bin/integration_runner


build-agent: build-integration-runner
@for PHP in $(PHPS); do \
echo "=====[php-$${PHP}]======"; \
ver=`echo $$PHP | cut -d '-' -f 1`; \
docker compose -f build-services.yml exec php-$${ver} make agent; \
echo "Saving agent/modules/newrelic.so to ./newrelic-for-php-$${ver}.so"; \
cp agent/modules/newrelic.so "./newrelic-for-php-$${ver}.so"; \
docker compose -f build-services.yml exec php-$${ver} make agent-clean; \
done

LOGLEVEL=info
run-tests:
@for PHP in $(PHPS); do \
echo "=====[php-$${PHP}]======"; \
ver=`echo $$PHP | cut -d '-' -f 1`; \
docker compose -f build-services.yml --env-file integration-tests.env exec php-$${ver} bin/integration_runner -agent ./newrelic-for-php-$${ver}.so -loglevel $(LOGLEVEL) $$TESTS; \
done
78 changes: 78 additions & 0 deletions build-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
services:
go:
image: newrelic/nr-php-agent-builder:make-go-${LIBC:-gnu}
extends:
file: common-services.yml
service: go-base

php-7.0:
extends:
file: common-services.yml
service: php-base
image: newrelic/nr-php-agent-builder:make-php-7.0-${LIBC:-gnu}
environment:
PHPS: "7.0"

php-7.1:
extends:
file: common-services.yml
service: php-base
image: newrelic/nr-php-agent-builder:make-php-7.1-${LIBC:-gnu}
environment:
PHPS: "7.1"

php-7.2:
extends:
file: common-services.yml
service: php-base
image: newrelic/nr-php-agent-builder:make-php-7.2-${LIBC:-gnu}
environment:
PHPS: "7.2"

php-7.3:
extends:
file: common-services.yml
service: php-base
image: newrelic/nr-php-agent-builder:make-php-7.3-${LIBC:-gnu}
environment:
PHPS: "7.3"

php-7.4:
extends:
file: common-services.yml
service: php-base
image: newrelic/nr-php-agent-builder:make-php-7.4-${LIBC:-gnu}
environment:
PHPS: "7.4"

php-8.0:
extends:
file: common-services.yml
service: php-base
image: newrelic/nr-php-agent-builder:make-php-8.0-${LIBC:-gnu}
environment:
PHPS: "8.0"

php-8.1:
extends:
file: common-services.yml
service: php-base
image: newrelic/nr-php-agent-builder:make-php-8.1-${LIBC:-gnu}
environment:
PHPS: "8.1"

php-8.2:
extends:
file: common-services.yml
service: php-base
image: newrelic/nr-php-agent-builder:make-php-8.2-${LIBC:-gnu}
environment:
PHPS: "8.2"

php-8.3:
extends:
file: common-services.yml
service: php-base
image: newrelic/nr-php-agent-builder:make-php-8.3-${LIBC:-gnu}
environment:
PHPS: "8.3"
52 changes: 52 additions & 0 deletions common-services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: '2.4'

services:
redis:
image: redis
restart: always
environment: &redis-env
REDIS_HOST: redisdb
ports:
- "6379:6379"
container_name: redisdb

mysql:
platform: linux/amd64
image: mysql:5.6
restart: always
environment: &mysql-env
MYSQL_ROOT_PASSWORD: admin
MYSQL_DATABASE: database
MYSQL_USER: admin
MYSQL_PASSWORD: admin
MYSQL_HOST: mysqldb
ports:
- "3306:3306"
healthcheck:
test: ["CMD", "mysql", "--user=admin", "--password=admin", "-e", "SELECT 1"]
interval: 10s
timeout: 10s
retries: 3
start_period: 20s
container_name: mysqldb

go-base:
# image: scratch
platform: ${PLATFORM:-}
entrypoint: tail
command: -f /dev/null
container_name: go
working_dir: ${PWD}
volumes:
- ${AGENT_CODE:-$PWD}:${PWD}

php-base:
# image: scratch
platform: ${PLATFORM:-}
environment:
<<: [*mysql-env, *redis-env]
entrypoint: tail
command: -f /dev/null
working_dir: ${PWD}
volumes:
- ${AGENT_CODE:-$PWD}:${PWD}

0 comments on commit 067c002

Please sign in to comment.