BluesparkLabs / spark

✨ Toolkit to develop, test and run Drupal websites.
MIT License
2 stars 1 forks source link

Platform.sh compatibility: workDir not writable #18

Closed jameswilson closed 6 years ago

jameswilson commented 6 years ago

Some of the commands such as the drupal:backup command generate output files that are stored temporarily in the webroot or in the repo-root.

As we know, the Platform.sh filesystem is read only except for a few exceptions like the tmp folder and any custom mounted folders like the Drupal private folder or the sites/default/files folder.

We need a general solution to store the output files to a writable and accessible directory on any environment and for any kind of project.

I'm not sure if we can make the assumption that /tmp is available on every system or not. So probably there needs to be a better way to specify the temporary folder on an environment-speicific basis. Random ideas:

jameswilson commented 6 years ago

I just tested Platform.sh and TMPDIR environment variable is undefined:

$ printenv | grep -i tmp

returned nothing at all.

So we'd need to then come up with a way for each project to copy .env.platformsh to .env or remember to add a custom environment variable on every project. This seems cumbersome and will lead to problems down the road.

@balintk I'm fresh out of ideas here about how to make this stupid simple.

jameswilson commented 6 years ago

Ok, so here is an idea:

1) look for TMPDIR environment variable getenv('TMPDIR'). 2) if undefined, determine if "/tmp" folder exists and is writable, and if so use that 3) if /tmp doesnt exist or is not writable, send a warning message and exit 1.

Platform.sh will fail at step 1, but pass at step 2.

jameswilson commented 6 years ago

Marking this as a blocker because it prevents us from using / testing spark drupal:backup on platform environment before sending untested or only locally-tested code to the client for testing on their linux environments.

jameswilson commented 6 years ago

Turns out Robo has its own Task for creating a tmp directory TmpDir, which relies on php sys_get_temp_dir.

All that needs to be done here is to update the drupal:backup command to use tmp directory in the paths.

jameswilson commented 6 years ago

@balintk PR #20 should solve this, would appreciate a review at earliest convenience.