Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit 9e661df

Browse files
committed
run composer if /vendor/ is not present
modified the Dockerfile to run composer, if the /vendor/ directory is not present. src\init_repo.sh is executed when the instance is launched. There's a check to see if /vendor/ already exists removed ( ) characters from xdebug.ini as they generated some errors in the comments # characters should not be used for comments
1 parent b98e77a commit 9e661df

File tree

3 files changed

+42
-31
lines changed

3 files changed

+42
-31
lines changed

.devcontainer/.docker/php/Dockerfile

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,11 @@ RUN curl -sS https://getcomposer.org/installer | php
5555
# copy composer to a place where it can be globally executed
5656
RUN mv composer.phar /usr/local/bin/composer
5757

58-
# NOT REQUIRED
59-
# Change to non-root privilege
60-
# USER www-data
58+
# our repo is in var/www/htdoc
59+
# COPY init_repo.sh /var/www/htdoc/
6160

62-
# Enable Error-logging in the PHP container
63-
# ----------------------------------------------------------
64-
65-
# RUN echo "error_log = /var/log/php-fpm.log" >> /usr/local/etc/php-fpm.d/docker.conf
66-
67-
#RUN echo "php_admin_value[error_log] = /var/log/php-fpm/www-error.log" >> /usr/local/etc/php-fpm.d/www.conf && \
68-
# echo "php_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf && \
69-
# echo "catch_workers_output = yes" >> /usr/local/etc/php-fpm.d/www.conf
61+
# Set the working directory in the container
62+
WORKDIR /var/www/htdoc
7063

64+
# start out script that runs composer install, but ONLY if /vendor/ does not exist
65+
ENTRYPOINT ["/var/www/htdoc/init_repo.sh"]
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
# already loaded in /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
2-
#zend_extension=xdebug
1+
; already loaded in /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
2+
;zend_extension=xdebug
33

44
; FIXME : should be elsewhere, like docker-php.ini
55
error_log = /var/log/php-errors.log
66
catch_workers_output = yes
77

88
[xdebug]
9-
# 'debug' means we're enabling step-by-step debugging
9+
; 'debug' means we're enabling step-by-step debugging
1010
xdebug.mode=debug
1111

1212
xdebug.client_port=9003
1313

14-
# xdebug.client_host is the IP address of the system where VS Code runs
15-
# that IP address is DIFFERENT depending on WHERE VS Code is launched in (Windows/Mac, WSL(2), Container/devcontainer/codespaces)
16-
#
17-
# the PHP container sends debugging data OUT to xdebug.client_host:xdebug.client_port
14+
; xdebug.client_host is the IP address of the system where VS Code runs
15+
; that IP address is DIFFERENT depending on WHERE VS Code is launched in Windows/Mac, WSL, Container/devcontainer/codespaces
16+
;
17+
; the PHP container sends debugging data OUT to xdebug.client_host:xdebug.client_port
1818

1919

20-
# localhost is used when running btoh VS Code and PHP from within **the same PHP container**
21-
# after opening the project in the Container
20+
; localhost is used when running btoh VS Code and PHP from within **the same PHP container**
21+
; after opening the project in the Container
2222
xdebug.client_host=localhost
2323

24-
# if using Docker Desktop 'host.docker.internal' is supposed to hold the IP Address of
25-
# the Docker host, but that's not always true. DOUBLE-CHECK
24+
; if using Docker Desktop 'host.docker.internal' is supposed to hold the IP Address of
25+
; the Docker host, but that's not always true. DOUBLE-CHECK
2626

2727
;xdebug.client_host=host.docker.internal
2828

29-
# 'yes': This will always initiate a debugging, profiling, or tracing session as soon as a request is received, without needing any specific trigger
30-
# 'no' : This will never initiate a session regardless of the presence of any trigger
31-
# 'trigger' : This will initiate a session only if a specific trigger (like a GET/POST variable or a cookie) is present in the request.
29+
; 'yes': This will always initiate a debugging, profiling, or tracing session as soon as a request is received, without needing any specific trigger
30+
; 'no' : This will never initiate a session regardless of the presence of any trigger
31+
; 'trigger' : This will initiate a session only if a specific trigger, like a GET/POST variable or a cookie, is present in the request.
3232
xdebug.start_with_request=yes
3333

34-
# OPTIONAL: idekey
35-
# in the browser add a URL param (if not using a browser utility)
36-
# url.to.debug?XDEBUG_SESSION_START=PHPSTORM
37-
# sets up a coockie called "XDEBUG_SESSION_START" with the value "PHPSTORM", which is the "trigger"
38-
# xdebug.idekey=PHPSTORM
34+
; OPTIONAL: idekey
35+
; in the browser add a URL param , if not using a browser utility
36+
; url.to.debug?XDEBUG_SESSION_START=PHPSTORM
37+
; sets up a coockie called "XDEBUG_SESSION_START" with the value "PHPSTORM", which is the "trigger"
38+
; xdebug.idekey=PHPSTORM
3939

40-
# defines a log file. This is created (touch) and initialized (permissions) in the PHP container Dockerfile
40+
; defines a log file. This is created, with touch, and initialized (permissions) in the PHP container Dockerfile
4141
xdebug.log=/tmp/xdebug.log

src/init_repo.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
# Navigate to your application directory
4+
cd /var/www/htdoc
5+
6+
# displays the current path, for debugging
7+
# pwd
8+
9+
# Check if the vendor directory does not exist
10+
if [ ! -d "vendor" ]; then
11+
# Run composer install
12+
composer install
13+
fi
14+
15+
# Then, execute the main command, e.g., starting PHP-FPM
16+
exec php-fpm

0 commit comments

Comments
 (0)