shopware: NEXT-6651 - Using remote filesystem breaks frontend and backend

Description
When using a remote filesystem (S3, Google Cloud, CDN) according to the docs the frontend and backend (plugins) styles and javascript are broken.

This is because Shopware saves these files on the remote filesystem on theme compilation but the URLs still point to the relative /themes (frontend) and /bundles (backend) paths.

Possible Solution
Respect the filesystem when generating asset URLs or save compiled theme files always on local.

Additional context
shopware.yaml:

shopware:
  filesystem:
    public:
      type: "amazon-s3"
      config:
        bucket: "%env(AWS_PUBLIC_BUCKET)%"
        region: "%env(AWS_PUBLIC_REGION)%"
        options:
          visibility: "public"
    private:
      type: "amazon-s3"
      config:
        bucket: "%env(AWS_PRIVATE_BUCKET)%"
        region: "%env(AWS_PRIVATE_REGION)%"
        options:
          visibility: "private"
  cdn:
    url: "%env(SHOPWARE_CDN)%"

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Yes the public files (media) and assets are mixed up. But they are not similar => they should have used a different filesystem. The Symfony asset component that is used is not using Flysystem internally. Therefore all asset links generated in the frontend will always assume local files.

A clean solution would be to introduce a new filesystem service for static resources and assets and completely separate them from media.

parameters:
    filesystem_local_public:
        type: 'local'
        config:
            root: '%kernel.project_dir%/public'

services:
    filesystem.local.public:
        class: 'League\Flysystem\FilesystemInterface'
        factory: ['@Shopware\Core\Framework\Adapter\Filesystem\FilesystemFactory', 'factory']
        arguments:
            - '%filesystem_local_public%'

    Shopware\Storefront\Theme\ThemeCompiler:
        arguments:
            - '@filesystem.local.public'
            - '@Shopware\Storefront\Theme\ThemeFileResolver'
            - '%kernel.cache_dir%'
            - '%kernel.debug%'

Is just one workaround atm for that issue.