Skip to content
Open
Show file tree
Hide file tree
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
60 changes: 29 additions & 31 deletions .docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.4-fpm
FROM php:8.3-fpm

RUN apt-get update

Expand All @@ -8,37 +8,35 @@ RUN apt-get install -y \
procps \
rsync \
unzip \
&& docker-php-ext-install zip

# Install MySQL
RUN docker-php-ext-configure mysqli -with-mysqli=mysqlnd \
&& docker-php-ext-configure pdo_mysql -with-pdo-mysql=mysqlnd \
&& docker-php-ext-install pdo pdo_mysql mysqli

# Install GD
RUN apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libxpm-dev

RUN docker-php-ext-configure gd --with-freetype=/usr/include/ \
--with-jpeg=/usr/include/ \
--with-xpm=/usr/include/ \
--enable-gd-jis-conv \
&& docker-php-ext-install gd


# Install xdebug
RUN pecl install xdebug-3.0.4 \
&& docker-php-ext-enable xdebug

COPY --from=composer /usr/bin/composer /usr/bin/composer

COPY config/php.ini /usr/local/etc/php/conf.d/
&& mkdir -p /var/spool/cron/crontabs \
&& echo '* * * * * /var/www/bin/playsmsd /var/www/etc/playsmsd.conf start' > /var/spool/cron/crontabs/www-data \
&& rm -rf /var/lib/apt/lists/*

# Install PHP extensions
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync \
&& install-php-extensions \
gd \
mysqli \
pdo \
pdo_mysql \
pdo_pgsql \
xdebug \
zip \
@composer \
&& rm /usr/local/bin/install-php-extensions \
# pevent errors when try to create files at /var/www with user www-data
&& chown -R www-data /var/www

# Workaround to make sure /usr/bin/php exists, some scripts expect it
RUN PHP_PATH=$(which php) && \
if [ ! -f "/usr/bin/php" ] && [ -n "$PHP_PATH" ] && [ "$PHP_PATH" != "/usr/bin/php" ]; then \
ln -s /usr/local/bin/php /usr/bin/php; \
fi

COPY config/php/* /usr/local/etc/php/conf.d/

WORKDIR /var/www/html
RUN mkdir /var/www/scripts
COPY entrypoint.sh /var/www/scripts/entrypoint.sh
COPY install.php /var/www/scripts/install.php
COPY scripts/* /var/www/scripts/
ENTRYPOINT [ "bash", "/var/www/scripts/entrypoint.sh" ]
3 changes: 0 additions & 3 deletions .docker/app/config/php.ini → .docker/app/config/php/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ post_max_size=512M
upload_max_filesize=512M
memory_limit=1024M
apc.enable_cli=1
xdebug.mode=develop,debug
xdebug.output_dir=/var/www/html
xdebug.start_with_request=yes
5 changes: 5 additions & 0 deletions .docker/app/config/php/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
xdebug.client_host=host.docker.internal
xdebug.discover_client_host=true
xdebug.log_level=0
xdebug.mode=debug
xdebug.start_with_request=yes
22 changes: 0 additions & 22 deletions .docker/app/install.php

This file was deleted.

52 changes: 52 additions & 0 deletions .docker/app/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
. `pwd`/../.env

# Set uid of host machine
usermod --non-unique --uid "${HOST_UID}" www-data
groupmod --non-unique --gid "${HOST_GID}" www-data

PHP_PATH=$(which php)

if [ ! -f "index.php" ]; then
git clone --progress --single-branch --depth 1 --branch "${VERSION_PLAYSMS}" --recurse-submodules -j 4 https://github.com/playsms/playsms /tmp/playsms
rsync -r /tmp/playsms/ ${PATHSRC}
mkdir -p $PATHWEB $PATHLOG $PATHSRC $PATHBIN $PATHCONF $PATHLIB
cp -rf $PATHSRC/web/* $PATHWEB
cp -f $PATHWEB/config-env.php $PATHWEB/config.php

cp $PATHSRC/daemon/linux/bin/playsmsd.php $PATHBIN/playsmsd
chmod 700 $PATHBIN/playsmsd
> $PATHCONF/playsmsd.conf
echo "PLAYSMS_PATH=\"$PATHWEB\"" > $PATHCONF/playsmsd.conf
echo "PLAYSMS_LIB=\"$PATHLIB\"" >> $PATHCONF/playsmsd.conf
echo "PLAYSMS_BIN=\"$PATHBIN\"" >> $PATHCONF/playsmsd.conf
echo "PLAYSMS_LOG=\"$PATHLOG\"" >> $PATHCONF/playsmsd.conf
echo "DAEMON_SLEEP=\"1\"" >> $PATHCONF/playsmsd.conf
echo "ERROR_REPORTING=\"E_ALL ^ (E_NOTICE | E_WARNING)\"" >> $PATHCONF/playsmsd.conf
echo "* * * * * $PATHBIN/playsmsd $PATHCONF/playsmsd.conf start" > /var/spool/cron/crontabs/www-data

composer --working-dir="$PATHSRC/" install

> $PATHLOG/playsms.log >/dev/null 2>&1
chmod 664 $PATHLOG/playsms.log >/dev/null 2>&1

touch $PATHLOG/audit.log >/dev/null 2>&1
chmod 664 $PATHLOG/audit.log >/dev/null 2>&1

chown -R www-data: $PATHWEB $PATHLOG $PATHSRC $PATHBIN $PATHCONF $PATHLIB
php /var/www/scripts/install.php
echo "🥳 Setup completed !!!"
fi
export PLAYSMS_WEB="$PATHWEB"
sleep 5
runuser -u www-data -- php $PATHBIN/playsmsd $PATHCONF/playsmsd.conf check
runuser -u www-data -- php $PATHBIN/playsmsd $PATHCONF/playsmsd.conf restart
runuser -u www-data -- php $PATHBIN/playsmsd $PATHCONF/playsmsd.conf status

# Start PHP-FPM
if [[ "$HTTP_PORT" != 80 ]]; then
echo "💜 playSMS is up! Access http://localhost:$HTTP_PORT"
else
echo "💜 playSMS is up! Access http://localhost"
fi
php-fpm
22 changes: 22 additions & 0 deletions .docker/app/scripts/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

function dbIsUp() {
try {
$dsn = "mysql:host={$_ENV['MYSQL_HOST']};dbname={$_ENV['MYSQL_DBNAME']}";
@new PDO($dsn, $_ENV['MYSQL_USER'], $_ENV['MYSQL_PWD']);
} catch(Exception $e) {
echo "⛔ Unable to conect to 🐬 mysql server: " . $e->getMessage()."\n";
return false;
}
return true;
}
while(!dbIsUp()) {
sleep(1);
}

echo "▶️ Setup database...\n";
$dbh= new PDO("mysql:host={$_ENV['MYSQL_HOST']};dbname={$_ENV['MYSQL_DBNAME']}", $_ENV['MYSQL_USER'], $_ENV['MYSQL_PWD']);
$dbh->exec(file_get_contents($_ENV['PATHSRC'] . '/db/playsms.sql'));
$dbh->exec("SET AUTOCOMMIT = 1;UPDATE playsms_tblUser SET password='" . password_hash($_ENV['ADMINPASSWORD'], PASSWORD_BCRYPT) . "',salt='' WHERE uid=1;");
echo "Setup database finished...\n";
echo "✅ Database 🐬 mysql ready\n";
1 change: 0 additions & 1 deletion .docker/mysql/conf/config.cnf
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[mysqld]
default_authentication_plugin=mysql_native_password
innodb_file_per_table=ON
31 changes: 0 additions & 31 deletions .env.example

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode
.env
volumes
18 changes: 0 additions & 18 deletions .vscode/launch.json

This file was deleted.

57 changes: 30 additions & 27 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.7"

services:
mysql:
image: mysql
Expand All @@ -8,46 +6,51 @@ services:
- ./volumes/mysql/dump:/docker-entrypoint-initdb.d
- ./volumes/mysql/data:/var/lib/mysql
ports:
- 3306:3306
- ${MYSQL_PORT:-3306}:3306
restart: unless-stopped
environment:
- TZ
- MYSQL_ROOT_PASSWORD
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
- TZ=${TZ:-CET}
- MYSQL_HOST=${MYSQL_HOST:-mysql}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root}
- MYSQL_DATABASE=${MYSQL_DATABASE:-playsms}
- MYSQL_USER=${MYSQL_USER:-playsms}
- MYSQL_PASSWORD=${MYSQL_PASSWORD:-playsms}
nginx:
build: .docker/web
restart: unless-stopped
volumes:
- ./volumes/playsms/html:/var/www/html:ro
- ./volumes/playsms/data/src/web:/var/www/html:ro
- ./volumes/nginx/includes:/etc/nginx/conf.d/includes/
ports:
- ${HTTP_PORT}:80
- ${HTTP_PORT:-80}:80
mailhog:
image: blueimp/mailhog
ports:
- ${MAILHOG_PORT}:8025
- ${MAILHOG_PORT:-8025}:8025
playsms:
build: .docker/app
volumes:
- ~/.composer:/root/.composer/
- ./.env:/var/www/.env
- ./volumes/playsms/data:/var/www/data
- ./volumes/playsms/html:/var/www/html
- ./volumes/playsms/data/src/web:/var/www/html
environment:
- TZ
- ADMINPASSWORD
- DBUSER
- DBPASS
- DBNAME
- DBHOST
- DBPORT
- URLWEB
- PATHWEB
- PATHBIN
- PATHLOG
- PATHSTR
- PATHSRC
- PLAYSMS_WEB
- XDEBUG_CONFIG
- HOST_UID=${HOST_UID:-1000}
- HOST_GID=${HOST_GID:-1000}
- TZ=${TZ:-CET}
- VERSION_PLAYSMS=${VERSION_PLAYSMS:-1.4.x}
- ADMINPASSWORD=${ADMINPASSWORD:-admin}
- MYSQL_USER=${MYSQL_USER:-playsms}
- MYSQL_PWD=${MYSQL_PWD:-playsms}
- MYSQL_DBNAME=${MYSQL_DBNAME:-playsms}
- MYSQL_HOST=${MYSQL_HOST:-mysql}
- URLWEB=${URLWEB:-http://localhost} # Adjust according to your HTTP_PORT, i.e. http://localhost:8080
- PATHWEB=${PATHWEB:-/var/www/data/src/web}
- PATHBIN=${PATHBIN:-/var/www/data/bin}
- PATHLOG=${PATHLOG:-/var/www/data/log}
- PATHLIB=${PATHLIB:-/var/www/data/src/web/lib}
- PATHSRC=${PATHSRC:-/var/www/data/src}
- PATHCONF=${PATHCONF:-/var/www/data/etc}
- PLAYSMS_WEB=${PLAYSMS_WEB:-/var/www/html}
- IS_HTTPS=${IS_HTTPS:-false}
- XDEBUG_CONFIG=${XDEBUG_CONFIG:-client_host=host.docker.internal client_port=9003 start_with_request=yes}