drainpipe icon indicating copy to clipboard operation
drainpipe copied to clipboard

Improve or reconsider including task via composer

Open deviantintegral opened this issue 2 years ago • 5 comments

Requiring task via composer means that when you want to run tasks that don't actually need composer you have to bootstrap it. Off the top of my head:

  • deploy:git
  • deploy:archive
  • terminus

all may not need composer. As well, when bootstrapping a new clone, you may have tasks that run composer install, but you have to run composer install before you can do something like task build:dev or task composer:install.

I think for ddev projects, it makes sense to install task via the Dockerfile, just like how composer or terminus is. However, there isn't an easy way to ensure the right version is installed to match drainpipe.

Ideas:

  • Task for linux is only 5MB. We could treat it as a scaffold file, and then it's always available from the start?
    • If we do this, we'd have to commit and manage all OS and arch combinations. However, that looks to be somewhat broken right now, because in my arm container I'm getting an amd64 task binary.
  • Make an easy way to identify what version of task drainpipe wants, without having to run PHP. Then a dockerfile could pull the right version down? The downside being is it requires a container restart to update, unless we make sure to overwrite the same location in vendor/bin/*.

deviantintegral avatar Feb 08 '23 16:02 deviantintegral

@deviantintegral if we could keep the versions in sync is there any downside to having both available? i.e. the composer installed version as well as a global one for ddev

justafish avatar Mar 02 '23 13:03 justafish

I don't think so. The hard part is "keep the versions in sync".

Is there a way we can include the task version in the composer.lock file? Then we could use jq to install task in vendor/bin without bootstrapping composer.

deviantintegral avatar Mar 02 '23 16:03 deviantintegral

Would including task via composer resolve these errors?

Checking for latest local-php-security-checker releases ...
Downloading local-php-security-checker_2.0.6_linux_386...
Symlinking local-php-security-checker_2.0.6_linux_386 as local-php-security-checker in composer bin-dir.
Creating initial Taskfile.yml...
Creating initial .gitignore...

In ScaffoldInstallerPlugin.php line 179:

  file_get_contents(composer.json): Failed to open stream: No such file or directory


install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]

composer [install --no-interaction --no-cache] failed, composer command failed: exit status 1. stderr=


~ ddev composer install 

Gathering patches for root package.
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package doctrine/reflection is abandoned, you should avoid using it. Use roave/better-reflection instead.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package symfony/debug is abandoned, you should avoid using it. Use symfony/error-handler instead.
Generating autoload files
90 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
PHP CodeSniffer Config installed_paths set to ../../drupal/coder/coder_sniffer,../../sirbrillig/phpcs-variable-analysis,../../slevomat/coding-standard

In Filesystem.php line 254:

  /dev/null/files/lullabot/drainpipe/bin/task/3.18.0 does not exist and could not be created.


install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]

composer [install --no-interaction --no-cache] failed, composer command failed: exit status 1. stderr=

mrdavidburns avatar Apr 05 '23 15:04 mrdavidburns

I think including task via composer (as we currently do) is causing these errors.

Given we are very much tied to ddev in drainpipe, I think it would make sense for us to add a Dockerfile.task file to the web directory that downloads task to /usr/local/bin/. The biggest downside is that changes wouldn't apply until you restarted ddev. However, I think that we could change the composer side to simply validate the right version of task is available without making any filesystem changes.

deviantintegral avatar Apr 10 '23 17:04 deviantintegral

+1 for including necessary command binaries via Dockerfile, I've found it the most reliable way and they're ready to use as soon as DDEV starts without composer. On another project which had a shared DDEV config that included this file:

# Include global composer in the path
ENV PATH="~/.composer/vendor/bin:${PATH}"

# Install Robo
RUN curl -fsSL -o /usr/local/bin/robo "https://github.com/davereid/robo/releases/latest/download/robo.phar" && chmod +x /usr/local/bin/robo

# Install Task
RUN sh -c "$(curl -fsSL https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin

# Install yq
RUN curl -fsSL -o /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/v4.40.3/yq_linux_amd64" && chmod +x /usr/local/bin/yq

# Install python as a dependency for techdocs
RUN DEBIAN_FRONTEND=noninteractive apt-get -qq install -o Dpkg::Options::="--force-confold" --no-install-recommends --no-install-suggests -y \
    python-is-python3 \
    python3-pip

# Install techdocs plugins.
RUN pip3 install mkdocs-techdocs-core==1.2.0
RUN pip3 install mkdocs-awesome-pages-plugin==2.9.1
RUN pip3 install mkdocs-literate-nav==0.6.0
RUN pip3 install mkdocs-macros-plugin==1.0.4
RUN pip3 install mkdocs-gen-files==0.5.0
RUN pip3 install mkdocs-section-index==0.3.5
RUN pip3 install mkdocs-techdocs-redirects==0.1.2
RUN pip3 install mkdocs-ezlinked-plugin==0.3.3

# Symlink the code root directory to mirror Pantheon hosting file structure.
RUN ln -s /var/www/html /code

davereid avatar Mar 22 '24 17:03 davereid