Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Clubphp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Clubphp
Commits
d25685f8
Commit
d25685f8
authored
Apr 07, 2026
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update 3 files via Son of Anton
parent
6b497a21
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
150 additions
and
56 deletions
+150
-56
Dockerfile
Dockerfile
+2
-2
boot.php
docker/boot.php
+127
-0
entrypoint.sh
docker/entrypoint.sh
+21
-54
No files found.
Dockerfile
View file @
d25685f8
...
...
@@ -53,7 +53,7 @@ RUN chown -R www-data:www-data /var/www/html/storage \
&&
chown
-R
www-data:www-data /var/www/html/public
\
&&
chmod
-R
755 /var/www/html/public
# ── Environment
(overridable via
CapRover env vars) ──
# ── Environment
defaults (overridden by
CapRover env vars) ──
ENV
APP_URL=http://localhost
ENV
APP_DEBUG=true
ENV
APP_ENV=local
...
...
@@ -66,7 +66,7 @@ ENV SMS_PROVIDER=
ENV
SMS_API_KEY=
ENV
SMS_SENDER_ID=
# ── Entrypoint — fix line endings
then copy
──
# ── Entrypoint — fix line endings ──
COPY
docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN
dos2unix /usr/local/bin/entrypoint.sh
&&
chmod
+x /usr/local/bin/entrypoint.sh
...
...
docker/boot.php
0 → 100644
View file @
d25685f8
<?php
declare
(
strict_types
=
1
);
/**
* Pre-boot script: waits for MySQL, creates DB, runs migrations & seeds.
* Called from entrypoint.sh — no shell escaping bullshit.
*/
echo
"=== Boot Script Starting ===
\n
"
;
// Read env vars
$host
=
getenv
(
'DB_HOST'
)
?:
'localhost'
;
$port
=
getenv
(
'DB_PORT'
)
?:
'3306'
;
$user
=
getenv
(
'DB_USER'
)
?:
'root'
;
$pass
=
getenv
(
'DB_PASS'
)
?:
''
;
$name
=
getenv
(
'DB_NAME'
)
?:
'the_club_erp'
;
echo
"DB_HOST:
{
$host
}
\n
"
;
echo
"DB_PORT:
{
$port
}
\n
"
;
echo
"DB_NAME:
{
$name
}
\n
"
;
echo
"DB_USER:
{
$user
}
\n
"
;
echo
"DB_PASS: "
.
(
strlen
(
$pass
)
>
0
?
'***SET***'
:
'***EMPTY***'
)
.
"
\n
"
;
// ── Wait for MySQL ──
echo
"
\n
Waiting for MySQL...
\n
"
;
$maxTries
=
30
;
$pdo
=
null
;
for
(
$i
=
1
;
$i
<=
$maxTries
;
$i
++
)
{
try
{
$pdo
=
new
PDO
(
"mysql:host=
{
$host
}
;port=
{
$port
}
"
,
$user
,
$pass
,
[
PDO
::
ATTR_ERRMODE
=>
PDO
::
ERRMODE_EXCEPTION
,
]);
echo
"MySQL is ready!
\n
"
;
break
;
}
catch
(
PDOException
$e
)
{
echo
" Attempt
{
$i
}
/
{
$maxTries
}
: "
.
$e
->
getMessage
()
.
"
\n
"
;
if
(
$i
>=
$maxTries
)
{
echo
"FATAL: MySQL not available after
{
$maxTries
}
attempts.
\n
"
;
exit
(
1
);
}
sleep
(
2
);
}
}
// ── Create database ──
echo
"
\n
Creating database '
{
$name
}
' if not exists...
\n
"
;
try
{
$pdo
->
exec
(
"CREATE DATABASE IF NOT EXISTS `
{
$name
}
` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"
);
echo
"Database ready!
\n
"
;
}
catch
(
PDOException
$e
)
{
echo
"FATAL: Could not create database: "
.
$e
->
getMessage
()
.
"
\n
"
;
exit
(
1
);
}
$pdo
=
null
;
// close connection
// ── Run Migrations ──
echo
"
\n
========================================
\n
"
;
echo
"Running Migrations...
\n
"
;
echo
"========================================
\n
"
;
chdir
(
'/var/www/html'
);
require_once
'/var/www/html/app/Core/Autoloader.php'
;
\App\Core\Autoloader
::
register
();
// Load .env
$envFile
=
'/var/www/html/.env'
;
if
(
file_exists
(
$envFile
))
{
$lines
=
file
(
$envFile
,
FILE_IGNORE_NEW_LINES
|
FILE_SKIP_EMPTY_LINES
);
foreach
(
$lines
as
$line
)
{
$line
=
trim
(
$line
);
if
(
$line
===
''
||
$line
[
0
]
===
'#'
)
continue
;
if
(
str_contains
(
$line
,
'='
))
{
[
$k
,
$v
]
=
explode
(
'='
,
$line
,
2
);
$k
=
trim
(
$k
);
$v
=
trim
(
$v
);
if
(
!
isset
(
$_ENV
[
$k
]))
{
$_ENV
[
$k
]
=
$v
;
putenv
(
"
{
$k
}
=
{
$v
}
"
);
}
}
}
}
try
{
$db
=
new
\App\Core\Database
(
$host
,
(
int
)
$port
,
$name
,
$user
,
$pass
,
'utf8mb4'
);
$migrationRunner
=
new
\App\Core\Migration\MigrationRunner
(
$db
);
$migrated
=
$migrationRunner
->
migrate
();
if
(
empty
(
$migrated
))
{
echo
"Nothing to migrate.
\n
"
;
}
else
{
echo
"Ran "
.
count
(
$migrated
)
.
" migration(s):
\n
"
;
foreach
(
$migrated
as
$m
)
{
echo
" +
{
$m
}
\n
"
;
}
}
}
catch
(
Throwable
$e
)
{
echo
"Migration error: "
.
$e
->
getMessage
()
.
"
\n
"
;
echo
"File: "
.
$e
->
getFile
()
.
":"
.
$e
->
getLine
()
.
"
\n
"
;
echo
"Continuing anyway...
\n
"
;
}
// ── Run Seeds ──
echo
"
\n
========================================
\n
"
;
echo
"Running Seeds...
\n
"
;
echo
"========================================
\n
"
;
try
{
$seederRunner
=
new
\App\Core\Seeder\SeederRunner
(
$db
);
$seeded
=
$seederRunner
->
run
();
if
(
empty
(
$seeded
))
{
echo
"Nothing to seed.
\n
"
;
}
else
{
echo
"Ran "
.
count
(
$seeded
)
.
" seed(s):
\n
"
;
foreach
(
$seeded
as
$s
)
{
echo
" +
{
$s
}
\n
"
;
}
}
}
catch
(
Throwable
$e
)
{
echo
"Seed error: "
.
$e
->
getMessage
()
.
"
\n
"
;
echo
"File: "
.
$e
->
getFile
()
.
":"
.
$e
->
getLine
()
.
"
\n
"
;
echo
"Continuing anyway...
\n
"
;
}
echo
"
\n
=== Boot Script Complete ===
\n
"
;
\ No newline at end of file
docker/entrypoint.sh
View file @
d25685f8
...
...
@@ -7,64 +7,31 @@ echo "========================================="
# ── Generate .env from environment variables ──
ENV_FILE
=
"/var/www/html/.env"
cat
>
"
$ENV_FILE
"
<<
ENVEOF
APP_URL=
${
APP_URL
:-
http
://localhost
}
APP_DEBUG=
${
APP_DEBUG
:-
true
}
APP_ENV=
${
APP_ENV
:-
local
}
DB_HOST=
${
DB_HOST
:-
localhost
}
DB_PORT=
${
DB_PORT
:-
3306
}
DB_NAME=
${
DB_NAME
:-
the_club_erp
}
DB_USER=
${
DB_USER
:-
root
}
DB_PASS=
${
DB_PASS
:-}
SMS_PROVIDER=
${
SMS_PROVIDER
:-}
SMS_API_KEY=
${
SMS_API_KEY
:-}
SMS_SENDER_ID=
${
SMS_SENDER_ID
:-}
ENVEOF
chown
www-data:www-data
"
$ENV_FILE
"
echo
".env generated!"
cat
>
"
$ENV_FILE
"
<<
'
ENDOFENV
'
APP_URL=PLACEHOLDER
ENDOFENV
# ── Wait for MySQL using PHP (avoids shell escaping issues) ──
echo
"Waiting for MySQL..."
MAX_TRIES
=
30
COUNT
=
0
until
php
-r
"
\$
h='
${
DB_HOST
}
';
\$
P='
${
DB_PORT
}
';
\$
u='
${
DB_USER
}
';
\$
p='
${
DB_PASS
}
';
try { new PDO(
\"
mysql:host=
\$
h;port=
\$
P
\"
,
\$
u,
\$
p); echo 'OK'; exit(0); }
catch(Exception
\$
e) { exit(1); }
"
2>/dev/null
;
do
COUNT
=
$((
COUNT
+
1
))
if
[
$COUNT
-ge
$MAX_TRIES
]
;
then
echo
"MySQL not ready after
${
MAX_TRIES
}
attempts. Starting Apache anyway..."
exec
apache2-foreground
fi
echo
" Attempt
${
COUNT
}
/
${
MAX_TRIES
}
..."
sleep
2
done
echo
"MySQL is ready!"
# ── Create database if needed (using PHP) ──
echo
"Ensuring database '
${
DB_NAME
}
' exists..."
# Write env properly using PHP (no shell escaping issues)
php
-r
"
\$
h='
${
DB_HOST
}
';
\$
P='
${
DB_PORT
}
';
\$
u='
${
DB_USER
}
';
\$
p='
${
DB_PASS
}
';
\$
d='
${
DB_NAME
}
';
\$
pdo = new PDO(
\"
mysql:host=
\$
h;port=
\$
P
\"
,
\$
u,
\$
p);
\$
pdo->exec(
\"
CREATE DATABASE IF NOT EXISTS
\\\`\$
d
\\\`
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
\"
);
echo 'Database ready!';
file_put_contents('/var/www/html/.env',
'APP_URL=' . getenv('APP_URL') .
\"\n\"
.
'APP_DEBUG=' . getenv('APP_DEBUG') .
\"\n\"
.
'APP_ENV=' . getenv('APP_ENV') .
\"\n\"
.
'DB_HOST=' . getenv('DB_HOST') .
\"\n\"
.
'DB_PORT=' . getenv('DB_PORT') .
\"\n\"
.
'DB_NAME=' . getenv('DB_NAME') .
\"\n\"
.
'DB_USER=' . getenv('DB_USER') .
\"\n\"
.
'DB_PASS=' . getenv('DB_PASS') .
\"\n\"
.
'SMS_PROVIDER=' . getenv('SMS_PROVIDER') .
\"\n\"
.
'SMS_API_KEY=' . getenv('SMS_API_KEY') .
\"\n\"
.
'SMS_SENDER_ID=' . getenv('SMS_SENDER_ID') .
\"\n\"
);
echo 'ENV file written!';
"
chown
www-data:www-data /var/www/html/.env
# ── Run Migrations ──
echo
"========================================="
echo
"Running Migrations..."
echo
"========================================="
cd
/var/www/html
php cli.php migrate 2>&1
||
echo
"Migration had issues, continuing..."
echo
"Migrations complete!"
# ── Run Seeds ──
echo
"========================================="
echo
"Running Seeds..."
echo
"========================================="
php cli.php seed 2>&1
||
echo
"Seeding had issues, continuing..."
echo
"Seeds complete!"
# ── Run boot script (MySQL wait + migrations + seeds) ──
php /var/www/html/docker/boot.php
# ── Fix permissions ──
chown
-R
www-data:www-data /var/www/html/storage 2>/dev/null
||
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment