Skip to content

tom00/shopware-kubernetes-dev

Repository files navigation

Shopware-Franken-Kube Concept

This concept is to test out Shopware PHP static build and compiled in application. All in a single binary. It is based on FrankenPHP and static-php-cli projects. Note that a static binary is built for production environments only. The dev version is based on dunglas/frankenphp image, because it is not possible to compile xdebug into the binary version. The application is copied to a container ready to be deployed to a Kubernetes cluster.

Build container images

Build dev image

docker build --target=app-dev --progress=plain -t shopware-bin-dev .

Build production image

docker build --target=app-prod --progress=plain -t shopware-bin .

Start standalone container

PHP Server

Production:

docker run --rm --name=shopware-bin -p 8000:8000 shopware-bin php-server -l 0.0.0.0:8000 -a -v --no-compress 

Development:

docker run --rm --name=shopware-bin -p 8000:8000 shopware-bin-dev php-server -l 0.0.0.0:8000 -a -v --no-compress 

Run PHP-cli commands

docker run --rm --name=shopware-bin shopware-bin php-cli bin/console

Configure Kubernetes cluster

Shopware cluster requires the following components to be available upfront:

  • Ingress controller (e.g. NGINX Ingress Controller, Traefik or HAProxy).
  • Object storage with S3 compatible API (e.g., MinIO).
  • Secret generator to automatically generate passwords.
  • Sealed secrets to encrypt secrets that cannot be auto-generated, so they can be securely stored in the repository.

Create a local Minikube Kubernetes cluster

./create_cluster.sh

Setup in-cluster test domains

Add two test domains into your hosts file.

echo '127.0.0.1 media.test shopware.test' | sudo tee -a /etc/hosts

Get the minikube node IP address

minikube ip

Add .test domain into the CoreDNS config pasting the node IP address.

kubectl edit configmap coredns -n kube-system

Append the following into the Corefile and replace 192.168.49.2 with your actual IP address returned by minikube ip.

    test:53 {
        errors
        cache 30
        forward . 192.168.49.2
    }

Build and run on Minikube using Skaffold

First delete shopware-init job if it exists

kubectl delete job/shopware-init -n shopware

Then run

skaffold run --force=true --tolerate-failures-until-deadline=true

Access MinIO GUI

kubectl port-forward -n shopware pod/minio-shopware-pool0-0 9443:9443

The GUI is available at https://localhost:9443

The default username and password are: minio:minio123.

MinIO public readonly policy

{
    "Version": "2012-10-17",
    "Statement": [

      {
        "Action": [
          "s3:GetBucketLocation",
          "s3:ListBucket"
        ],
        "Effect": "Allow",
        "Principal": {
          "AWS": [
            "*"
          ]
        },
        "Resource": [
          "arn:aws:s3:::public"
        ],
        "Sid": ""
      },
      {
        "Action": [
          "s3:GetObject"
        ],
        "Effect": "Allow",
        "Principal": {
          "AWS": [
            "*"
          ]
        },
        "Resource": [
          "arn:aws:s3:::public/*"
        ],
        "Sid": ""
      }        
    ]
}

Open tunnel for storefront and media ingresses

minikube tunnel

Reverse tunnel for Xdebug using ktunnel

ktunnel inject deployment app-server-dev 9003

Port forward shopware dev server

kubectl port-forward deploy/app-server-dev -n shopware 8000:8000

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published