Skip to content

Commit c72221c

Browse files
committed
chore: update to latest version
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent f00f038 commit c72221c

File tree

12 files changed

+173
-117
lines changed

12 files changed

+173
-117
lines changed

.docker/app/Dockerfile

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.4-fpm
1+
FROM php:8.3-fpm
22

33
RUN apt-get update
44

@@ -8,37 +8,29 @@ RUN apt-get install -y \
88
procps \
99
rsync \
1010
unzip \
11-
&& docker-php-ext-install zip
12-
13-
# Install MySQL
14-
RUN docker-php-ext-configure mysqli -with-mysqli=mysqlnd \
15-
&& docker-php-ext-configure pdo_mysql -with-pdo-mysql=mysqlnd \
16-
&& docker-php-ext-install pdo pdo_mysql mysqli
17-
18-
# Install GD
19-
RUN apt-get install -y \
20-
libfreetype6-dev \
21-
libjpeg62-turbo-dev \
22-
libpng-dev \
23-
libxpm-dev
24-
25-
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ \
26-
--with-jpeg=/usr/include/ \
27-
--with-xpm=/usr/include/ \
28-
--enable-gd-jis-conv \
29-
&& docker-php-ext-install gd
30-
31-
32-
# Install xdebug
33-
RUN pecl install xdebug-3.0.4 \
34-
&& docker-php-ext-enable xdebug
35-
36-
COPY --from=composer /usr/bin/composer /usr/bin/composer
37-
38-
COPY config/php.ini /usr/local/etc/php/conf.d/
11+
&& mkdir -p /var/spool/cron/crontabs \
12+
&& echo '* * * * * /var/www/bin/playsmsd /var/www/etc/playsmsd.conf start' > /var/spool/cron/crontabs/www-data \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# Install PHP extensions
16+
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
17+
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync \
18+
&& install-php-extensions \
19+
gd \
20+
mysqli \
21+
pdo \
22+
pdo_mysql \
23+
pdo_pgsql \
24+
xdebug \
25+
zip \
26+
@composer \
27+
&& rm /usr/local/bin/install-php-extensions \
28+
# pevent errors when try to create files at /var/www with user www-data
29+
&& chown -R www-data /var/www
30+
31+
COPY config/php/* /usr/local/etc/php/conf.d/
3932

4033
WORKDIR /var/www/html
4134
RUN mkdir /var/www/scripts
42-
COPY entrypoint.sh /var/www/scripts/entrypoint.sh
43-
COPY install.php /var/www/scripts/install.php
35+
COPY scripts/* /var/www/scripts/
4436
ENTRYPOINT [ "bash", "/var/www/scripts/entrypoint.sh" ]
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@ post_max_size=512M
33
upload_max_filesize=512M
44
memory_limit=1024M
55
apc.enable_cli=1
6-
xdebug.mode=develop,debug
7-
xdebug.output_dir=/var/www/html
8-
xdebug.start_with_request=yes

.docker/app/config/php/xdebug.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
xdebug.client_host=host.docker.internal
2+
xdebug.discover_client_host=true
3+
xdebug.log_level=0
4+
xdebug.mode=debug
5+
xdebug.start_with_request=yes

.docker/app/install.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

.docker/app/scripts/entrypoint.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
. `pwd`/../.env
3+
4+
# Set uid of host machine
5+
usermod --non-unique --uid "${HOST_UID}" www-data
6+
groupmod --non-unique --gid "${HOST_GID}" www-data
7+
8+
PHP_PATH=$(which php)
9+
10+
if [ ! -f "index.php" ]; then
11+
if [ ! -f "/usr/bin/php" ] && [ -n "$PHP_PATH" ] && [ "$PHP_PATH" != "/usr/bin/php" ]; then
12+
ln -s /usr/local/bin/php /usr/bin/php
13+
fi
14+
15+
git clone --progress --single-branch --depth 1 --branch "${VERSION_PLAYSMS}" --recurse-submodules -j 4 https://github.com/playsms/playsms /tmp/playsms
16+
rsync -r /tmp/playsms/ ${PATHSRC}
17+
mkdir -p $PATHWEB $PATHLOG $PATHSRC $PATHBIN $PATHCONF $PATHLIB
18+
cp -rf $PATHSRC/web/* $PATHWEB
19+
cp -f $PATHWEB/config-env.php $PATHWEB/config.php
20+
21+
cp $PATHSRC/daemon/linux/bin/playsmsd.php $PATHBIN/playsmsd
22+
chmod 700 $PATHBIN/playsmsd
23+
> $PATHCONF/playsmsd.conf
24+
echo "PLAYSMS_PATH=\"$PATHWEB\"" > $PATHCONF/playsmsd.conf
25+
echo "PLAYSMS_LIB=\"$PATHLIB\"" >> $PATHCONF/playsmsd.conf
26+
echo "PLAYSMS_BIN=\"$PATHBIN\"" >> $PATHCONF/playsmsd.conf
27+
echo "PLAYSMS_LOG=\"$PATHLOG\"" >> $PATHCONF/playsmsd.conf
28+
echo "DAEMON_SLEEP=\"1\"" >> $PATHCONF/playsmsd.conf
29+
echo "ERROR_REPORTING=\"E_ALL ^ (E_NOTICE | E_WARNING)\"" >> $PATHCONF/playsmsd.conf
30+
echo "* * * * * $PATHBIN/playsmsd $PATHCONF/playsmsd.conf start" > /var/spool/cron/crontabs/www-data
31+
32+
composer --working-dir="$PATHSRC/" install
33+
34+
> $PATHLOG/playsms.log >/dev/null 2>&1
35+
chmod 664 $PATHLOG/playsms.log >/dev/null 2>&1
36+
37+
touch $PATHLOG/audit.log >/dev/null 2>&1
38+
chmod 664 $PATHLOG/audit.log >/dev/null 2>&1
39+
40+
chown -R www-data: $PATHWEB $PATHLOG $PATHSRC $PATHBIN $PATHCONF $PATHLIB
41+
php /var/www/scripts/install.php
42+
echo "🥳 Setup completed !!!"
43+
fi
44+
export PLAYSMS_WEB="$PATHWEB"
45+
sleep 5
46+
runuser -u www-data -- php $PATHBIN/playsmsd $PATHCONF/playsmsd.conf check
47+
runuser -u www-data -- php $PATHBIN/playsmsd $PATHCONF/playsmsd.conf restart
48+
runuser -u www-data -- php $PATHBIN/playsmsd $PATHCONF/playsmsd.conf status
49+
50+
# Start PHP-FPM
51+
if [[ "$HTTP_PORT" != 80 ]]; then
52+
echo "💜 playSMS is up! Access http://localhost:$HTTP_PORT"
53+
else
54+
echo "💜 playSMS is up! Access http://localhost"
55+
fi
56+
php-fpm

.docker/app/scripts/install.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
function dbIsUp() {
4+
try {
5+
$dsn = "mysql:host={$_ENV['MYSQL_HOST']};dbname={$_ENV['MYSQL_DBNAME']}";
6+
@new PDO($dsn, $_ENV['MYSQL_USER'], $_ENV['MYSQL_PWD']);
7+
} catch(Exception $e) {
8+
echo "⛔ Unable to conect to 🐬 mysql server: " . $e->getMessage()."\n";
9+
return false;
10+
}
11+
return true;
12+
}
13+
while(!dbIsUp()) {
14+
sleep(1);
15+
}
16+
17+
echo "▶️ Setup database...\n";
18+
$dbh= new PDO("mysql:host={$_ENV['MYSQL_HOST']};dbname={$_ENV['MYSQL_DBNAME']}", $_ENV['MYSQL_USER'], $_ENV['MYSQL_PWD']);
19+
$dbh->exec(file_get_contents($_ENV['PATHSRC'] . '/db/playsms.sql'));
20+
$dbh->exec("SET AUTOCOMMIT = 1;UPDATE playsms_tblUser SET password='" . password_hash($_ENV['ADMINPASSWORD'], PASSWORD_BCRYPT) . "',salt='' WHERE uid=1;");
21+
echo "Setup database finished...\n";
22+
echo "✅ Database 🐬 mysql ready\n";
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env php
2+
<?php
3+
$dbName = (getenv('DB_HOST') === 'mysql' ? '🐬' : '🐘' ) . getenv('DB_HOST');
4+
5+
echo "⌛ Waiting for database $dbName\n";
6+
7+
function dbIsUp(string $dbName): bool {
8+
try {
9+
if (getenv('DB_HOST') === 'mysql') {
10+
$dsn = getenv('DB_HOST') . ':dbname='.getenv('MYSQL_DATABASE').';host='.getenv('DB_HOST');
11+
new PDO($dsn, getenv('MYSQL_USER'), getenv('MYSQL_PASSWORD'));
12+
} elseif (getenv('DB_HOST') === 'pgsql') {
13+
$dsn = getenv('DB_HOST') . ':dbname='.getenv('POSTGRES_DB').';host='.getenv('DB_HOST');
14+
new PDO($dsn, getenv('POSTGRES_USER'), getenv('POSTGRES_PASSWORD'));
15+
} else {
16+
// Will use SQLite
17+
return true;
18+
}
19+
} catch(Exception $e) {
20+
echo "⛔ Unable to conect to $dbName server: " . $e->getMessage()."\n";
21+
return false;
22+
}
23+
return true;
24+
}
25+
26+
while(!dbIsUp($dbName)) {
27+
sleep(1);
28+
}
29+
30+
echo "✅ Database $dbName ready\n";

.docker/mysql/conf/config.cnf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
[mysqld]
2-
default_authentication_plugin=mysql_native_password
32
innodb_file_per_table=ON

.env.example

Lines changed: 0 additions & 31 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
.vscode
12
.env
23
volumes

0 commit comments

Comments
 (0)