Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: custom environment to run Shopware 6 #169

Closed
gfilice opened this issue Jun 20, 2020 · 11 comments
Closed

Feature Request: custom environment to run Shopware 6 #169

gfilice opened this issue Jun 20, 2020 · 11 comments
Labels
enhancement New feature or request
Milestone

Comments

@gfilice
Copy link

gfilice commented Jun 20, 2020

I would like to have the opportunity to create a custom environment to run Shopware 6 (link to doc).
The major problem is that Shopware write a .env file in root folder, overriding the warden env.
Any suggestion would be appreciated.

@davidalger
Copy link
Collaborator

@gfilice I ran through installing Shopware over the weekend on here, based on the Symfony env type so I could see what you're referring to. Noting here that both the bin/setup (method which should be used in Warden env) and psh.phar overwrite the .env file. @lbajsarowicz alluded to issues like this when he introduced a Symfony env type as possibly being an issue with Symfony setups in general.

As an interesting note, I found this as well. I'm curious, do you know if this is Shopware specific or Symfony in general?
Screen-Shot-2020-06-22-14-31-18 69-OdzemkdIRs2s

In order to test installing it myself, I went ahead and added a basic shopware env type with Mutagen configuration for file-sync. This is based on the symfony type (only difference at the moment being the addition of the Mutagen sync support). See the commits above, or checkout latest develop to test this.

As a recommended workaround to avoid the .env overlap for the time being, I would suggest setting WARDEN_WEB_ROOT=/webroot and installing Shopware 6 into a sub-directory like I've done in the following example, avoiding the collision. With this setup, you should be able to run bin/setup to install, entering the appropriate db connection details (note you'll probably want to use root user, pw shopware, host db to avoid an error creating the shopware_test database).

davidalger:/sites/sh6$ tree -L 2 -a .
.
├── .env
└── webroot
    ├── .editorconfig
    ├── .env
    ├── .env.dist
    ├── .git
    ├── .gitignore
    ├── .gitlab-ci.yml
    ├── .psh.yaml.dist
    ├── .psh.yaml.override
    ├── README.md
    ├── bin
    ├── build
    ├── composer.json
    ├── config
    ├── custom
    ├── dev-ops
    ├── docker-compose.yml
    ├── docker-sync.yml
    ├── ide-twig.json
    ├── license.txt
    ├── phpunit.xml.dist
    ├── platform
    ├── psh.phar
    ├── public
    └── src

10 directories, 16 files

As someone who hasn't actually developed a site on Shopware 6, I'd love feedback from some who has on what containers should be included in a Shopware environment by default. I know it can use Elasticsearch, Varnish and Redis, but are they typically used or would requiring users enable them by adding a var to .env be ok?

Feedback on what directories should/could be excluded from the Mutagen sync would be good as well. On Magento 2 for example, pub/media is excluded and instead mounted via Docker volume configuration to avoid syncing large quantities of images, and ./var is excluded as it contains largely transient data such as logs not usually needed on the host (prevent constant sync churn basically). I'm guessing var/cache would be a good candidate to exclude starting off.

@gfilice
Copy link
Author

gfilice commented Jun 23, 2020

Thank you @davidalger.
Please can you share some details about the Shopware installation procedures you used (if I use the web install I got the message "The options driver or driverClass are mandatory if no PDO instance is given to DriverManager::getConnection()."

@davidalger
Copy link
Collaborator

@gfilice I'm not sure why that error would show up since I haven't used Shopware beyond installing it at this point. What I did to install is paste the following into my shell:

mkdir sh6 \
&& cd sh6 \
&& warden env-init sh6 shopware \
&& warden sign-certificate sh6.test \
&& git clone git@github.com:shopware/development.git webroot \
&& perl -pi -e 's#^WARDEN_WEB_ROOT.*#WARDEN_WEB_ROOT=/webroot#' .env \
&& warden env pull \
&& warden env up \
&& echo $'const:\n  APP_URL: "https://app.sh6.test"\n  DB_HOST: "db"\n  DB_NAME: "shopware"\n  DB_USER: "root"\n  DB_PASSWORD: "shopware"' > webroot/.psh.yaml.override \
&& warden shell -c './psh.phar install'

Those last two lines could be replaced by entering the environment via warden shell and then running bin/setup for interactive prompts requesting the db connection info, site URL, etc. The above string of commands will result in a fully installed copy of Shopware 6 with sample data.

When the above is done, you should be met with the following (output of the install command at the very end):

Duration: 5m 30s
All commands successfully executed!

After I run the above, pop open https://app.sh6.test/ in my browser and voila! A working Shopware installation:
Screen-Shot-2020-06-23-06-28-00 90-eYkanld1bqbt

@gfilice
Copy link
Author

gfilice commented Jun 23, 2020

Unfortunately, I have an error during Shopware setup from cli:
Schermata del 2020-06-23 19-03-52

@davidalger
Copy link
Collaborator

Does it work if you include an install of make/g++ ( I noticed when I ran it, the npm install had warnings about make being missing for me…it just didn't kill it ). I may need to add make/g++ to the images.

mkdir sh6 \
&& cd sh6 \
&& warden env-init sh6 shopware \
&& warden sign-certificate sh6.test \
&& git clone git@github.com:shopware/development.git webroot \
&& perl -pi -e 's#^WARDEN_WEB_ROOT.*#WARDEN_WEB_ROOT=/webroot#' .env \
&& warden env pull \
&& warden env up \
&& echo $'const:\n  APP_URL: "https://app.sh6.test"\n  DB_HOST: "db"\n  DB_NAME: "shopware"\n  DB_USER: "root"\n  DB_PASSWORD: "shopware"' > webroot/.psh.yaml.override \
&& warden shell -c 'sudo yum install -y make gcc-c++' \
&& warden shell -c './psh.phar install'

@gfilice
Copy link
Author

gfilice commented Jun 24, 2020

Doesn't work @davidalger ... I've always the error Cannot find module 'semver'
Schermata del 2020-06-24 09-22-04

@davidalger
Copy link
Collaborator

@gfilice Assuming you're starting from a completely clean environment, I'm afraid I'm not sure what to say to that one since I cannot reproduce it, and I've spun up a Shopware 6 site using the above chained commands over half a dozen time without failure so I'm a bit at a loss. If you search for that Cannot find module semver error, there are a TON of people who experience it, and some of the solutions are supposedly as simple as re-installing NPM (which shouldn't apply here since npm is run in a container) 🤷‍♂️

Unless I can be convinced the NPM install issue you're having is specific to Warden, I'm probably going to allow this to close when I tag Warden 0.6.0 which includes the new shopware environment type. Although I wish I could say what was going wrong on that front, I don't believe it's a problem with Warden or the container images given it's not happening in any of the tests I've done.

I'm adding make and gcc-c++ to the php-fpm images so they'll be there when npm needs them via commit 1e0577b and hope to write a documentation page on initializing a Shopware environment either before or shortly after I publish this.

@davidalger davidalger added the enhancement New feature or request label Jun 27, 2020
@gfilice
Copy link
Author

gfilice commented Jun 28, 2020

Thank you @davidalger!
After spending a few hours working on the permissions and the owner of the folders, I successfully installed Shopware 6 in warden environment. Now it works fine!!!
Now I just have to figure out how to install Shopware plugins in a local environment...

davidalger added a commit that referenced this issue Jun 29, 2020
davidalger added a commit that referenced this issue Jun 29, 2020
@davidalger
Copy link
Collaborator

@gfilice Very good to hear!

@davidalger
Copy link
Collaborator

The functionality here has been released in version 0.6.0. Please refer to #173 for info on forthcoming documentation covering how to install Shopware 6 in a Warden environment context.

@snowcore
Copy link
Contributor

Now Shopware 6 requires composer 2, so don't forget to switch composer version before installation: #296 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants