Skip to content

Commit

Permalink
switch to wolfi php base image
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Apr 20, 2024
1 parent c90fac8 commit 328f5a4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 27 deletions.
72 changes: 49 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ARG PHP_VERSION=8.3
FROM friendsofshopware/shopware-cli:latest-php-${PHP_VERSION} as creation
FROM friendsofshopware/shopware-cli:latest-php-8.3 as creation
ARG SHOPWARE_VERSION=6.5.8.2

RUN <<EOF
Expand All @@ -23,47 +22,74 @@ shopware:
frw: false
EOF

FROM shopware/docker-base:${PHP_VERSION}-caddy
FROM ghcr.io/shyim/wolfi-php/nginx:8.3

COPY --from=creation /shop /var/www/html

ENV DATABASE_URL=mysql://root:root@localhost/shopware
ENV DATABASE_URL=mysql://root:root@localhost/shopware \
PHP_MEMORY_LIMIT=512M \
COMPOSER_ROOT_VERSION=1.0.0 \
APP_URL=http://localhost:8000

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

USER root

RUN <<EOF
set -e
apk add --no-cache mariadb mariadb-client
mysql_install_db --datadir=/var/lib/mysql --user=www-data
mkdir /run/mysqld/ && chown -R www-data /run/mysqld/
EOF

COPY --chmod=555 <<EOF /usr/local/etc/php/conf.d/mysql-fix.ini
pdo_mysql.default_socket=/run/mysqld/mysqld.sock
mysqli.default_socket=/run/mysqld/mysqld.sock
EOF

COPY --chmod=555 <<EOF /usr/local/etc/php/conf.d/99-opcache-dev.ini
opcache.enable_file_override=0

apk add --no-cache \
php-8.3 \
php-8.3-fileinfo \
php-8.3-openssl \
php-8.3-ctype \
php-8.3-curl \
php-8.3-xml \
php-8.3-dom \
php-8.3-phar \
php-8.3-simplexml \
php-8.3-xmlreader \
php-8.3-xmlwriter \
php-8.3-bcmath \
php-8.3-iconv \
php-8.3-gd \
php-8.3-intl \
php-8.3-pdo \
php-8.3-pdo_mysql \
php-8.3-mysqlnd \
php-8.3-pcntl \
php-8.3-sockets \
php-8.3-bz2 \
php-8.3-gmp \
php-8.3-soap \
php-8.3-zip \
php-8.3-sodium \
php-8.3-opcache \
mariadb-11.2 \
jq
EOF

RUN <<EOF
set -e
/usr/bin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=www-data &
set -x
mkdir -p /var/tmp /run/mysqld
mariadb-install-db --datadir=/var/lib/mariadb --user=root

/usr/bin/mariadbd --basedir=/usr --datadir=/var/lib/mariadb --plugin-dir=/usr/lib/mariadb/plugin --user=root &
sleep 2
mysqladmin --user=root password 'root'
mariadb-admin --user=root password 'root'
php bin/console system:install --create-database --force
mysql -proot shopware -e "DELETE FROM sales_channel WHERE id = 0x98432def39fc4624b33213a56b8c944d"
mariadb -proot shopware -e "DELETE FROM sales_channel WHERE id = 0x98432def39fc4624b33213a56b8c944d"
php bin/console user:create "admin" --admin --password="shopware" -n
php bin/console sales-channel:create:storefront --name=Storefront --url="http://localhost/shop/public"
php bin/console theme:change --all Storefront
php bin/console plugin:refresh
php bin/console plugin:install --activate SwagPlatformDemoData
mysql -proot -e "SET GLOBAL innodb_fast_shutdown=0"
mysql -proot shopware -e "INSERT INTO system_config (id, configuration_key, configuration_value, sales_channel_id, created_at, updated_at) VALUES (0xb3ae4d7111114377af9480c4a0911111, 'core.frw.completedAt', '{\"_value\": \"2019-10-07T10:46:23+00:00\"}', NULL, '2019-10-07 10:46:23.169', NULL);"
chown -R www-data:www-data /var/www/html /var/lib/mysql/ /tmp/composer
php -derror_reporting=E_ALL bin/console plugin:install --activate SwagPlatformDemoData
mariadb -proot -e "SET GLOBAL innodb_fast_shutdown=0"
mariadb -proot shopware -e "INSERT INTO system_config (id, configuration_key, configuration_value, sales_channel_id, created_at, updated_at) VALUES (0xb3ae4d7111114377af9480c4a0911111, 'core.frw.completedAt', '{\"_value\": \"2019-10-07T10:46:23+00:00\"}', NULL, '2019-10-07 10:46:23.169', NULL);"
rm -rf var/cache/* /var/tmp/*
php bin/console
chown -R www-data:www-data /var/www/html /var/lib/mariadb/ /var/tmp /run/mysqld/
EOF

USER www-data
Expand Down
8 changes: 4 additions & 4 deletions rootfs/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
set -e
set -x

/usr/bin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql &
/usr/bin/mariadbd --basedir=/usr --datadir=/var/lib/mariadb --plugin-dir=/usr/lib/mariadb/plugin --user=www-data &

while ! mysqladmin ping --silent; do
while ! mariadb-admin ping --silent; do
sleep 1
done

if [[ -n $APP_URL ]]; then
mysql -proot shopware -e "UPDATE sales_channel_domain set url = '${APP_URL}'"
mariadb -uroot -proot shopware -e "UPDATE sales_channel_domain set url = '${APP_URL}'"
fi

if [[ ! -z $SHOPWARE_ADMIN_PASSWORD ]]; then
Expand Down Expand Up @@ -40,4 +40,4 @@ if [[ -f /var/www/html/fixture.php ]]; then
php -derror_reporting=E_ALL /var/www/html/fixture.php
fi

/usr/bin/supervisord -c /etc/supervisord.conf
exec /usr/bin/hivemind /etc/Procfile
1 change: 1 addition & 0 deletions rootfs/etc/php/conf.d/99-opcache-dev.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opcache.enable_file_override=0
2 changes: 2 additions & 0 deletions rootfs/etc/php/conf.d/mysql-fix.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pdo_mysql.default_socket=/run/mysqld/mysqld.sock
mysqli.default_socket=/run/mysqld/mysqld.sock

0 comments on commit 328f5a4

Please sign in to comment.