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

Support for Laravel version 11 and a "latest" version #14

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -2,12 +2,12 @@ SERVER_ROOT=/var/www/public
APP_CODE_PATH_HOST=/tmp/laravel
APP_CODE_CONTAINER_FLAG=:cached
APP_CODE_PATH_LARAVEL=/var/www
PHP_VERSION=7.4
PHP_VERSION=8.2
LARAVEL_HOST_HTTP_PORT=53487
DISPLAY_PHPERROR=true
XDEBUG=false
LARAVEL_VERSION=8
LARAVEL_VERSION=11
BACK_END=nginx
INSTALL_ADDITIONAL_EXTENSIONS=
USER_ID=1000
GROUP_ID=1000
GROUP_ID=1000
22 changes: 19 additions & 3 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -9,8 +9,24 @@ on:
jobs:
Laravel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the image with php 8.2 Laravel 11 and nginx
run: docker-compose -f "docker-compose.yml" up -d --build
env:
PHP_VERSION: "8.2"
LARAVEL_VERSION: 11
BACK_END: nginx
LARAVEL_INSTALL: true
XDEBUG: true
DISPLAY_PHPERROR: true
- name: Build the image with php 8.1 Laravel 11 and nginx
run: docker-compose -f "docker-compose.yml" up -d --build
env:
PHP_VERSION: "8.1"
LARAVEL_VERSION: 11
BACK_END: nginx
LARAVEL_INSTALL: true
XDEBUG: true
DISPLAY_PHPERROR: true
- name: Build the image with php 8.2 Laravel 10 and nginx
run: docker-compose -f "docker-compose.yml" up -d --build
env:
@@ -172,4 +188,4 @@ jobs:
BACK_END: apache
LARAVEL_INSTALL: true
XDEBUG: true
DISPLAY_PHPERROR: true
DISPLAY_PHPERROR: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
data
data
.idea
4 changes: 2 additions & 2 deletions laravel/apache/Dockerfile-8.3
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ RUN sed -i "s#{SERVER_ROOT}#/var/preview#g" /etc/apache2/httpd.conf
RUN sed -i "s#{SERVER_ROOT}#/var/www/public#g" /app/httpd.conf

# Persistent runtime dependencies
# Example RUN apk add --no-cache php82-openssl php82-sysvmsg php82-curl
# Example RUN apk add --no-cache php83-openssl php83-sysvmsg php83-curl

WORKDIR /var/www
ENV PHP_VERSION=83
@@ -58,7 +58,7 @@ RUN apk --no-cache add shadow sudo
RUN usermod -u ${USER_ID} apache && groupmod -g ${GROUP_ID} apache

# sudo command without password
RUN echo "apache ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN echo "apache ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN composer config --global process-timeout 6000

RUN sed -i "s#{USER_ID}#${USER_ID}#g" /docker-entrypoint.sh
93 changes: 54 additions & 39 deletions laravel/apache/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,66 @@
#!/bin/bash
set +x
if [[ $(curl -Is https://laravel.com | head -n 1 | cut -d ' ' -f 2 ) == "200" ]]; then
if [[ -f "/var/www/composer.json" ]] ;
then
cd /var/www/
if [[ -d "/var/www/vendor" ]] ;
then
echo "Steps to use Composer optimise autoloader"
sudo composer update --prefer-dist --no-interaction --optimize-autoloader --no-dev
echo "Steps to Clear All Development inputs"
sudo php artisan view:clear
sudo php artisan route:clear
sudo php artisan config:clear
sudo php artisan clear-compiled
else
echo "If composer vendor folder is not installed follow the below steps"
sudo composer install --prefer-dist --no-interaction --optimize-autoloader --no-dev
set +x # Disable verbose debugging output

# Check if Laravel website is accessible (indicating internet connectivity)
if [[ $(curl -Is https://laravel.com | head -n 1 | cut -d ' ' -f 2) == "200" ]]; then

# Check if we're in a Composer project directory
if [[ -f "/var/www/composer.json" ]]; then
cd /var/www/ # Change to project directory

# Check if vendor directory exists (Composer dependencies installed)
if [[ -d "/var/www/vendor" ]]; then
echo "Steps to use Composer optimise autoloader"
sudo composer update --prefer-dist --no-interaction --optimize-autoloader --no-dev

echo "Steps to Clear All Development inputs"
sudo php artisan view:clear
sudo php artisan route:clear
sudo php artisan config:clear
sudo php artisan clear-compiled
else
echo "If composer vendor folder is not installed follow the below steps"
sudo composer install --prefer-dist --no-interaction --optimize-autoloader --no-dev
fi
fi

fi
if [[ "$(ls -A "/var/www/")" ]] ;
then
# Check if the project directory is empty (excluding hidden files)
if [[ "$(ls -A "/var/www/")" ]]; then
echo "If the Directory is not empty, please delete the hidden files and directory"
else
sudo composer config --global process-timeout 6000
sudo composer create-project --prefer-dist laravel/laravel:^{LARAVEL_VERSION}.0 .
sudo composer config --global process-timeout 6000 # Set longer timeout

# Install Laravel based on version (or latest if not specified)
if [[ "{LARAVEL_VERSION}" == "latest" ]]; then
sudo composer create-project --prefer-dist laravel/laravel .
else
sudo composer create-project --prefer-dist laravel/laravel:^{LARAVEL_VERSION}.0 .
fi

# If Laravel installation fails, execute the default entrypoint script
if [ $? != 0 ]; then
sh /docker-entrypoint.sh
sh /docker-entrypoint.sh
fi
fi
echo "Steps to check application environment variable"
if [[ ! -f ".env" ]] ;
then
echo ".env file not found"
sudo cp .env.example .env
else
echo ".env file exit"
fi
sudo cp /app/httpd.conf /etc/apache2/httpd.conf
httpd -k graceful
sudo chown -R apache:apache /var/www 2> /dev/null
rm -rf /var/preview 2> /dev/null
fi

sudo php artisan key:generate
echo "Steps to check application environment variable"
# Ensure .env file exists for environment configuration
if [[ ! -f ".env" ]]; then
echo ".env file not found"
sudo cp .env.example .env
else
echo ".env file exists"
fi

exec "$@"
# Configure Apache, set permissions, clean up
sudo cp /app/httpd.conf /etc/apache2/httpd.conf
httpd -k graceful # Restart Apache gracefully
sudo chown -R apache:apache /var/www 2> /dev/null
rm -rf /var/preview 2> /dev/null

sudo php artisan key:generate # Generate Laravel application key

exec "$@" # Execute any passed arguments
else
echo "Internet not working check your Internet connection or network";
fi
fi
2 changes: 1 addition & 1 deletion laravel/nginx/Dockerfile-8.3
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ RUN sed -i "s#{SERVER_ROOT}#/var/www/public#g" /app/default.conf


# Persistent runtime dependencies
# Example RUN apk add --no-cache php82-openssl php82-sysvmsg php82-curl
# Example RUN apk add --no-cache php83-openssl php83-sysvmsg php83-curl

WORKDIR /var/www
ENV PHP_VERSION=83
94 changes: 55 additions & 39 deletions laravel/nginx/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,52 +1,68 @@
#!/bin/bash
set +x
if [[ $(curl -Is https://laravel.com | head -n 1 | cut -d ' ' -f 2 ) == "200" ]]; then
if [[ -f "/var/www/composer.json" ]] ;
then
cd /var/www/
if [[ -d "/var/www/vendor" ]] ;
then
echo "Steps to use Composer optimise autoloader"
sudo composer update --prefer-dist --no-interaction --optimize-autoloader --no-dev
echo "Steps to Clear All Development inputs"
sudo php artisan view:clear
sudo php artisan route:clear
sudo php artisan config:clear
sudo php artisan clear-compiled
else
echo "If composer vendor folder is not installed follow the below steps"
sudo composer install --prefer-dist --no-interaction --optimize-autoloader --no-dev
set +x # Disable verbose debugging output

# Check if Laravel website is accessible (indicating internet connectivity)
if [[ $(curl -Is https://laravel.com | head -n 1 | cut -d ' ' -f 2) == "200" ]]; then

# Check if we're in a Composer project directory
if [[ -f "/var/www/composer.json" ]]; then
cd /var/www/ # Change to project directory

# Check if vendor directory exists (Composer dependencies installed)
if [[ -d "/var/www/vendor" ]]; then
echo "Steps to use Composer optimise autoloader"
sudo composer update --prefer-dist --no-interaction --optimize-autoloader --no-dev

echo "Steps to Clear All Development inputs"
sudo php artisan view:clear
sudo php artisan route:clear
sudo php artisan config:clear
sudo php artisan clear-compiled
else
echo "If composer vendor folder is not installed follow the below steps"
sudo composer install --prefer-dist --no-interaction --optimize-autoloader --no-dev
fi
fi

fi
if [[ "$(ls -A "/var/www/")" ]] ;
then
# Check if the project directory is empty (excluding hidden files)
if [[ "$(ls -A "/var/www/")" ]]; then
echo "If the Directory is not empty, please delete the hidden files and directory"
else
sudo composer config --global process-timeout 6000
sudo composer create-project --prefer-dist laravel/laravel:^{LARAVEL_VERSION}.0 .
sudo composer config --global process-timeout 6000 # Set longer timeout

# Install Laravel based on version (or latest if not specified)
if [[ "{LARAVEL_VERSION}" == "latest" ]]; then
# If LARAVEL_VERSION is empty or "latest", install the latest version
sudo composer create-project --prefer-dist laravel/laravel .
else
# Otherwise, install the specified version
sudo composer create-project --prefer-dist laravel/laravel:^{LARAVEL_VERSION}.0 .
fi

# If Laravel installation fails, execute the default entrypoint script
if [ $? != 0 ]; then
sh /docker-entrypoint.sh
sh /docker-entrypoint.sh
fi
fi
echo "Steps to check application environment variable"
if [[ ! -f ".env" ]] ;
then
echo ".env file not found"
sudo cp .env.example .env
else
echo ".env file exit"
fi
fi

sudo cp /app/default.conf /etc/nginx/conf.d/default.conf
nginx -s reload
sudo chown -R nobody:nobody /var/www 2> /dev/null
echo "Steps to check application environment variable"
# Ensure .env file exists for environment configuration
if [[ ! -f ".env" ]]; then
echo ".env file not found"
sudo cp .env.example .env
else
echo ".env file exists"
fi

sudo rm -rf /var/preview 2> /dev/null
# Configure Nginx, set permissions, clean up
sudo cp /app/default.conf /etc/nginx/conf.d/default.conf
nginx -s reload # Reload Nginx configuration
sudo chown -R nobody:nobody /var/www 2> /dev/null # Set ownership to Nginx user
sudo rm -rf /var/preview 2> /dev/null

sudo php artisan key:generate
sudo php artisan key:generate # Generate Laravel application key

exec "$@"
exec "$@" # Execute any passed arguments
else
echo "Internet not working check your Internet connection or network";
fi
fi
2 changes: 1 addition & 1 deletion laravel/nginx/package.sh
Original file line number Diff line number Diff line change
@@ -4,4 +4,4 @@ for (( n=1; n<=$word; n++ ))
do
SERVER_ARRAY=`echo ${INSTALL_ADDITIONAL_EXTENSIONS} | awk '{print $'$n'}' | sed 's/.*-//'`
sudo apk add --no-cache php${PHP_VERSION}-`echo ${SERVER_ARRAY}`
done``
done
17 changes: 10 additions & 7 deletions settings.yml
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ user:
- nginx
target:
BACK_END

php_version:
label:
PHP version
@@ -20,13 +21,14 @@ user:
type:
select
values:
- 7.4
- "7.4"
- "8.0"
- 8.1
- "8.1"
- "8.2"
- "8.3"
target:
PHP_VERSION

backend_ws:
disabled_post_install: true
label:
@@ -36,10 +38,11 @@ user:
type:
select
values:
- 7
- 8
- 9
- "10"
- 10
- 11
- "latest"
target:
LARAVEL_VERSION

@@ -48,7 +51,7 @@ user:
Enable PHP error reporting?
type:
checkbox
hint: Check the box to display PHP errors
hint: Check the box to display PHP errors
target:
DISPLAY_PHPERROR
php_xdebug:
@@ -59,7 +62,7 @@ user:
hint: Check the box to display extension xdebug
target:
XDEBUG

# mysql_version:
# label:
# MySQL version