vessel icon indicating copy to clipboard operation
vessel copied to clipboard

Vapor support

Open sanderversluys opened this issue 6 years ago • 15 comments

Description

It's currently not possible to init a Vapor project with the default Vessel docker setup.

The vapor init and deploy script needs node and npm inside the docker container.

Laravel 6 also needs by default php-redis but this is already fixed in the vessel patch-2.

OS

MacOS Mojave

Docker

The output of docker version:

Client: Docker Engine - Community
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:26:49 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:32:21 2019
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          v1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

The output of docker-compose version:

docker-compose version 1.24.1, build 4667896b
docker-py version: 3.7.3
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.0j  20 Nov 2018

sanderversluys avatar Sep 13 '19 16:09 sanderversluys

Hi!

I think I need some help clarifying that.

Vessel Init

Here's what ./vessel init does: https://github.com/shipping-docker/vessel/blob/master/docker-files/vessel#L152-L217

I don't see where/how that might require NPM/Node installed in the app container? (Note that there is a separate container used for Node/NPM commands)

Deploy

There's no deploy command at all, so I'm not sure what you're saying there.

Let me know what you're seeing and I'm happy to help!

fideloper avatar Sep 13 '19 17:09 fideloper

Oh vessel init works just fine, I'm talking about the new vapor init and deploy commands. These rely on node and npm.

https://vapor.laravel.com/

This is the output from the vapor deploy command in the app container.

php vendor/bin/vapor deploy staging
Building project...
==> Copying Application Files
==> Harmonizing Configuration Files
==> Setting Build Environment
==> Executing Build Commands
==> Running Command: composer install --classmap-authoritative
Deprecation warning: Your package name mytrace-api is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9]([_.-]?[a-z0-9]+)*". Make sure you fix this as Composer 2.0 will error.
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: davidpiesse/nova-map
Discovered Package: drfraker/snipe-migrations
Discovered Package: ebess/advanced-nova-media-library
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: grimzy/laravel-mysql-spatial
Discovered Package: intervention/image
Discovered Package: laravel/horizon
Discovered Package: laravel/nova
Discovered Package: laravel/passport
Discovered Package: laravel/telescope
Discovered Package: laravel/tinker
Discovered Package: laravel/vapor-core
Discovered Package: mad-web/nova-horizon-link
Discovered Package: mad-web/nova-telescope-link
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: nunomaduro/phpinsights
Discovered Package: santigarcor/laratrust
Discovered Package: spatie/laravel-medialibrary
Discovered Package: spatie/laravel-translatable
Package manifest generated successfully.
==> Running Command: php artisan event:cache
Cached events cleared!
Events cached successfully!
==> Running Command: npm install && npm run dev && rm -rf node_modules
sh: 1: npm: not found

In Process.php line 254:
                                                                           
  The command "npm install && npm run dev && rm -rf node_modules" failed.  
                                                                           
  Exit Code: 127(Command not found)                                        
                                                                           
  Working directory: /var/www/.vapor/build/app                             
                                                                           
  Output:                                                                  
  ================                                                         
                                                                           
                                                                           
  Error Output:                                                            
  ================                                                         
  sh: 1: npm: not found                                                    
                                                                           

deploy [--commit [COMMIT]] [--message [MESSAGE]] [--without-waiting] [--] [<environment>]

I'm not saying you should add this as default but using Vapor with Vessel won't work out of the box and I guess it'll be very much an important tool for many Laravel developers in the future.

Btw I love Vessel. I'm trying to convince my team to use this instead of using completely different scripts for each project.

sanderversluys avatar Sep 14 '19 07:09 sanderversluys

Ah thank you, I didn’t read that correctly at all haha -

Ok, I’ll have to think on that. Maybe we just throw it all into one larger container...

On Sat, Sep 14, 2019 at 02:24 Sander Versluys [email protected] wrote:

Oh vessel init works just fine, I'm talking about the new vapor init and deploy commands. These rely on node and npm.

This is the output from the vapor deploy command in the app container.

php vendor/bin/vapor deploy staging Building project... ==> Copying Application Files ==> Harmonizing Configuration Files ==> Setting Build Environment ==> Executing Build Commands ==> Running Command: composer install --classmap-authoritative Deprecation warning: Your package name mytrace-api is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "a-z0-9/a-z0-9". Make sure you fix this as Composer 2.0 will error. Do not run Composer as root/super user! See https://getcomposer.org/root for details Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Generating optimized autoload files ocramius/package-versions: Generating version class... ocramius/package-versions: ...done generating version class

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi Discovered Package: beyondcode/laravel-dump-server Discovered Package: davidpiesse/nova-map Discovered Package: drfraker/snipe-migrations Discovered Package: ebess/advanced-nova-media-library Discovered Package: facade/ignition Discovered Package: fideloper/proxy Discovered Package: grimzy/laravel-mysql-spatial Discovered Package: intervention/image Discovered Package: laravel/horizon Discovered Package: laravel/nova Discovered Package: laravel/passport Discovered Package: laravel/telescope Discovered Package: laravel/tinker Discovered Package: laravel/vapor-core Discovered Package: mad-web/nova-horizon-link Discovered Package: mad-web/nova-telescope-link Discovered Package: nesbot/carbon Discovered Package: nunomaduro/collision Discovered Package: nunomaduro/phpinsights Discovered Package: santigarcor/laratrust Discovered Package: spatie/laravel-medialibrary Discovered Package: spatie/laravel-translatable Package manifest generated successfully. ==> Running Command: php artisan event:cache Cached events cleared! Events cached successfully! ==> Running Command: npm install && npm run dev && rm -rf node_modules sh: 1: npm: not found

In Process.php line 254:

The command "npm install && npm run dev && rm -rf node_modules" failed.

Exit Code: 127(Command not found)

Working directory: /var/www/.vapor/build/app

Output:

Error Output:

sh: 1: npm: not found

deploy [--commit [COMMIT]] [--message [MESSAGE]] [--without-waiting] [--] []

I'm not saying you should add this as default but using Vapor with Vessel won't work out of the box and I guess it'll be very much an important tool for many Laravel developers in the future.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/shipping-docker/vessel/issues/121?email_source=notifications&email_token=AADSDUYAVV3EXYSOVOYGXS3QJSGTTA5CNFSM4IWRZOA2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6WWLHA#issuecomment-531457436, or mute the thread https://github.com/notifications/unsubscribe-auth/AADSDU64GKDOU3MHB7BG3R3QJSGTTANCNFSM4IWRZOAQ .

fideloper avatar Sep 14 '19 11:09 fideloper

In the meantime, how could we make this work? Or would it only be possible with php/vapor installer etc installed on local machine directly?

madsem avatar Sep 17 '19 19:09 madsem

It's likely possible to run it locally if you have node/npm installed locally as well, yep!

Note that you may need to do something like:

TELESCOPE_ENABLED=false php vendor/bin/vapor deploy staging

...if your PHP env attempts to connect to Redis for telescope or other things while running that command.

fideloper avatar Sep 17 '19 19:09 fideloper

I just ran into the same issue, but with Laravel Nova... It's not possible to build Nova Tools/Resource Tools etc.

it always errors out with:

➜ vessel art nova:tool madsem/oauth2

 Would you like to install the tool's NPM dependencies? (yes/no) [yes]:
 >

sh: 1: npm: not found

madsem avatar Jun 24 '20 14:06 madsem

@madsem You will need to add node/npm to your app container. You can do this after container is running


vessel exec app

Then, when inside container, you will run the following


# curl -sL https://deb.nodesource.com/setup_12.x | bash
# apt-get install -y nodejs

When node is installed, it will also install npm

mikeerickson avatar Jun 24 '20 15:06 mikeerickson

Very nice! Thanks @mikeerickson appreciated :)

madsem avatar Jun 24 '20 15:06 madsem

Hi!

Note that running that command like that won’t save node into the app container image. That change will only be around until you turn the containers off (vis the down or stop commands).

On Wed, Jun 24, 2020 at 10:56 madsem [email protected] wrote:

Very nice! Thanks @mikeerickson https://github.com/mikeerickson appreciated :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/shipping-docker/vessel/issues/121#issuecomment-648908277, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSDU2C3UZLXR7XQMQT6HTRYIO3TANCNFSM4IWRZOAQ .

fideloper avatar Jun 24 '20 16:06 fideloper

Thanks @fideloper, that's not a big deal! Maybe it would be a good idea to indeed combine the app and node containers in a future relase though?

madsem avatar Jun 24 '20 16:06 madsem

Very true, so how about considering making it permanent and add to app Dockerfile (as I have done) because modern Laravel tooling has more requirements for presence of node/npm as opposed to using a separate container.

I realize the bigger picture is container all the things, but Laravel does not play nice internally with this approach.

It is still is good to have a node container around, but inside the context of Laravel tooling, adding node to app container has merit

Ok, all done :)

mikeerickson avatar Jun 24 '20 16:06 mikeerickson

Orrr intercept npm calls inside the app container and redirect them to the node container?

Just spitballing here, might be possible.

madsem avatar Jun 24 '20 16:06 madsem

@madsem or just use local install of node/npm and call it a day. I do nose work all day everyday in my normal workflow so locally installed node is an absolute must.

mikeerickson avatar Jun 24 '20 17:06 mikeerickson

@mikeerickson that is of course possible, and I also have npm installed. But not Redis... So then you'd always need to swap out .env settings before creating a Nova tool/using Vapor cli.

Overall I think easiest solution long-term would indeed be combining the containers. For me, I just added it to the projects Dockerfile for now.

madsem avatar Jun 25 '20 08:06 madsem

@madsem i didn’t mean doing everything locally, I was just referring to the actions that needed npm/node. I completely understand the desires to use containers for development work, I do the same here. However, since I don’t use vapor, I am not sure of your exact issue 🤓

mikeerickson avatar Jun 25 '20 14:06 mikeerickson