Add option to build current directory
i wanted to have a single container building the required assets.
Example:
build:
stage: build assets
image: akoehnlein/surf:php72
script:
- yarn config set cache-dir $CI_PROJECT_DIR/.caches/npm
- yarn install
- yarn production
artifacts:
paths:
- DistributionPackages/JoRo.Data/Resources/Public/JavaScript
- DistributionPackages/JoRo.Data/Resources/Public/Styles
expire_in: 1d
which works. Gitlab-ci hands over the artifacts to all other jobs which is awesome. The only problem is, Surf itself does all the Tasks in {workspace}-Folder. So my assets are not found by Surf.
With an option to build the current directory, it would be possible for Surf to use the existing data without recompiling or copying the existing asset where Surf can find it.
This would avoid doing dodgy stuff like
"cp " . dirname(__DIR__) . "/assets" . " " . $deployment->getWorkspacePath($application) . "/assets"
That's why I created npm tasks myself and execute npm in surf workspace.
For CI environments this could be a starting point. Either set an environment variable:
SURF_WORKSPACE=. surf ...
or set the path within the deployment with:
$deployment->setWorkspacesBasePath('.')
The main problem is that the RsyncTask (and others) gets their workspace path with $deployment->getWorkspacePath($application) which internally appends depoyment name + application name. This needs to be adjusted.
@ochorocho I don't think your workaround is too bad if you want to have it in different CI stages.
We also build with Surf:
->defineTask(
'BuildTask',
LocalShellTask::class, // could have used a \TYPO3\Surf\Task\Composer\CommandTask...
[
'command' => [
'cd {workspacePath} && composer build-for:deployment',
],
]
)
We use a composer script build-for:deployment (which is also used to build the local dev system and which reuses tasks used by the developers directly):
...
"scripts": {
"build-for:deployment": [
"@npm install",
"@build:all"
],
"build:all": [
"@npm run-script --silent gulp all"
],
...
"npm": [
"npm --prefix=./build/"
],
...
}
@simonschaufi Would like to close this issue. No reaction anymore. Feel free to reopen.
I wanted to make this work for v3 as this would be a killer feature that surf doesn't need to checkout the whole repo in CI context for example