Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Feb 5, 2024
0 parents commit fc91649
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build
on:
push:

env:
DOCKER_BUILDKIT: 1

permissions:
contents: read
packages: write

jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Nushell
uses: hustcer/[email protected]

- name: Generate Matrix
id: generate-matrix
run: |
MATRIX=$(nu matrix.nu)
echo "matrix<<EOF" >> $GITHUB_OUTPUT
echo "$MATRIX" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
build:
name: ${{ matrix.shopwareVersion }}
runs-on: ubuntu-latest
needs: [generate-matrix]
strategy: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login into Github Docker Registery
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- uses: docker/build-push-action@v5
with:
tags: friendsofshopware/shopware-demo-environment:${{ matrix.shopwareVersion }}
context: fpm
cache-from: type=gha,scope=${{ matrix.shopwareVersion }}
cache-to: type=gha,mode=max,scope=${{ matrix.shopwareVersion }}
platforms: linux/amd64
build-args: |
PHP_VERSION=${{ matrix.phpVersion }}
SHOPWARE_VERSION=${{ matrix.shopwareVersion }}
push: true
provenance: false
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
ARG PHP_VERSION=8.3
FROM friendsofshopware/shopware-cli:latest-php-${PHP_VERSION} as creation
ARG SHOPWARE_VERSION=6.5.8.2

RUN <<EOF
set -e
shopware-cli project create /shop ${SHOPWARE_VERSION}
shopware-cli project ci /shop
COMPOSER_ALLOW_SUPERUSER=1 composer -d /shop require "swag/demo-data:*"
EOF

FROM shopware/docker-base:${PHP_VERSION}-caddy

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

ENV DATABASE_URL=mysql://root:root@localhost/shopware

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

RUN <<EOF
set -e
/usr/bin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=www-data &
sleep 2
mysqladmin --user=root password 'root'
php bin/console system:install --create-database --force
mysql -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
EOF

USER www-data

COPY --link rootfs/ /

STOPSIGNAL SIGKILL

ENTRYPOINT ["/entrypoint.sh"]
Empty file added README.md
Empty file.
14 changes: 14 additions & 0 deletions matrix.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mut data = {
fail-fast: false,
matrix: {
include: []
}
}

let versions = http get https://raw.githubusercontent.com/FriendsOfShopware/shopware-static-data/main/data/php-version.json | items {|key, value|
{phpVersion: $value, shopwareVersion: $key}
} | filter {|item| $item.shopwareVersion | str starts-with "6.5" }

$data.matrix.include = $versions;

$data | to json
37 changes: 37 additions & 0 deletions rootfs/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env sh

set -e
set -x

/usr/bin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql &

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

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

if [[ ! -z $SHOPWARE_ADMIN_PASSWORD ]]; then
./bin/console user:change-password admin -n --password=$SHOPWARE_ADMIN_PASSWORD
fi

if [[ ! -z "$EXTENSIONS" ]]; then
if [[ ! -z "$SHOPWARE_PACKAGIST_TOKEN" ]]; then
composer config repositories.shopware-packages '{"type": "composer", "url": "https://packages.shopware.com"}'
composer config bearer.packages.shopware.com "$SHOPWARE_PACKAGIST_TOKEN"
fi

composer req $EXTENSIONS

php bin/console plugin:refresh

list_with_plugins=$(php bin/console plugin:list --json | jq 'map(select(.installedAt == null)) | .[].name' -r)

for plugin in $list_with_plugins; do
php bin/console plugin:install --activate "$plugin"
done
fi

/usr/bin/supervisord -c /etc/supervisord.conf

0 comments on commit fc91649

Please sign in to comment.