Surf icon indicating copy to clipboard operation
Surf copied to clipboard

Add option to build current directory

Open ochorocho opened this issue 7 years ago • 4 comments

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"

ochorocho avatar Mar 21 '19 09:03 ochorocho

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.

simonschaufi avatar Feb 16 '20 12:02 simonschaufi

@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/"
    ],
    ...
  }

jonaseberle avatar Jul 28 '21 10:07 jonaseberle

@simonschaufi Would like to close this issue. No reaction anymore. Feel free to reopen.

sabbelasichon avatar Jan 31 '22 21:01 sabbelasichon

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

simonschaufi avatar Feb 01 '22 04:02 simonschaufi