From ed41d6b9ef9b1d76a943417b054cd0480146cf0d Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Mon, 16 Dec 2024 09:31:45 -0500 Subject: [PATCH 1/3] fix QOL aliases The QOL aliases need to be defined in .bashrc of the container's default user. --- files/Dockerfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/files/Dockerfile b/files/Dockerfile index 3081cf1ab..769d2c0ba 100644 --- a/files/Dockerfile +++ b/files/Dockerfile @@ -142,16 +142,15 @@ ENV PHP_VER=${PHP_VER} ARG PS1 ENV PS1="New Relic > " -# QOL aliases -# `rebuild` - make clean + make agent + make tests -# `integ` - run all integration tests -RUN echo 'alias integ="/usr/src/myapp/bin/integration_runner -agent /usr/src/myapp/agent/.libs/newrelic.so"' >> ~/.bashrc \ - && echo 'alias rebuild="make -C agent clean && rm agent/Makefile && make && make tests"' >> ~/.bashrc - ARG USER=developer ARG UID=501 ARG GID=20 RUN useradd --uid ${UID} --gid ${GID} --shell /bin/bash --create-home ${USER} USER ${USER} +# QOL aliases +# `rebuild` - make clean + make agent + make tests +# `integ` - run all integration tests +RUN echo 'alias integ="/usr/src/myapp/bin/integration_runner -agent /usr/src/myapp/agent/.libs/newrelic.so"' >> ~/.bashrc \ + && echo 'alias rebuild="make -C agent clean && rm agent/Makefile && make && make tests"' >> ~/.bashrc WORKDIR /usr/src/myapp CMD ["bash"] From 7183989f29c8d80845bf34d6248eb19fd0e8901d Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Thu, 19 Dec 2024 13:30:11 -0500 Subject: [PATCH 2/3] allow multiple devenvs to run simultanously There is no need to expose ports to host - services within composer project can communicate with each other without ports being forwarded to host. Forwarding ports to host result in second instance of devenv fail to start because the ports are already used by first instance. There is also no need to name service containers because any interaction with the service container can be done by service name, e.g. `docker compose exec php`. --- docker-compose.yaml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 21044c7c7..b99c89dc0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -14,38 +14,26 @@ services: 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 volumes: - var-run-mysqld:/var/run/mysqld redisdb: image: redis restart: always - ports: - - "6379:6379" - container_name: redisdb memcached: image: memcached:latest restart: always - ports: - - "11211:11211" - container_name: memcached postgres: image: postgres restart: always environment: POSTGRES_PASSWORD: root POSTGRES_USER: postgres - ports: - - "5432:5432" - container_name: postgres php: platform: ${PLATFORM:-} image: newrelic/nr-php-agent-builder:make-php-${PHP:-8.2}-${LIBC:-gnu}-${IMAGE_VERSION:-v1} @@ -106,7 +94,6 @@ services: working_dir: /usr/src/myapp stdin_open: true tty: true - container_name: agent-devenv profiles: ["dev"] volumes: From ba7419b25df8165660965c740048dcc7ed55a1df Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Thu, 19 Dec 2024 15:49:19 -0500 Subject: [PATCH 3/3] make /usr/src/myapp/ a safe dir for git Avoid "fatal: detected dubious ownership in repository at '/usr/src/myapp/'" error when running git commands inside container with host volume mounted. --- files/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/Dockerfile b/files/Dockerfile index 769d2c0ba..cb52536ef 100644 --- a/files/Dockerfile +++ b/files/Dockerfile @@ -153,4 +153,7 @@ USER ${USER} RUN echo 'alias integ="/usr/src/myapp/bin/integration_runner -agent /usr/src/myapp/agent/.libs/newrelic.so"' >> ~/.bashrc \ && echo 'alias rebuild="make -C agent clean && rm agent/Makefile && make && make tests"' >> ~/.bashrc WORKDIR /usr/src/myapp +# Avoid "fatal: detected dubious ownership in repository at '/usr/src/myapp/'" error +# when running git commands inside container with host volume mounted: +RUN git config --global --add safe.directory /usr/src/myapp/ CMD ["bash"]