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

Add option to build current directory #267

Open
ochorocho opened this issue Mar 21, 2019 · 4 comments
Open

Add option to build current directory #267

ochorocho opened this issue Mar 21, 2019 · 4 comments

Comments

@ochorocho
Copy link
Contributor

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"
@simonschaufi
Copy link
Collaborator

simonschaufi commented Feb 16, 2020

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.

@jonaseberle
Copy link
Contributor

jonaseberle commented Jul 28, 2021

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

@sabbelasichon
Copy link
Collaborator

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

@simonschaufi
Copy link
Collaborator

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 simonschaufi reopened this Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants