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

Vapor support #121

Open
sanderversluys opened this issue Sep 13, 2019 · 15 comments
Open

Vapor support #121

sanderversluys opened this issue Sep 13, 2019 · 15 comments

Comments

@sanderversluys
Copy link

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
@fideloper
Copy link
Contributor

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!

@sanderversluys
Copy link
Author

sanderversluys commented Sep 14, 2019

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.

@fideloper
Copy link
Contributor

fideloper commented Sep 14, 2019 via email

@madsem
Copy link

madsem commented Sep 17, 2019

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?

@fideloper
Copy link
Contributor

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.

@madsem
Copy link

madsem commented Jun 24, 2020

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

@mikeerickson
Copy link
Contributor

mikeerickson commented Jun 24, 2020

@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

@madsem
Copy link

madsem commented Jun 24, 2020

Very nice! Thanks @mikeerickson appreciated :)

@fideloper
Copy link
Contributor

fideloper commented Jun 24, 2020 via email

@madsem
Copy link

madsem commented Jun 24, 2020

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?

@mikeerickson
Copy link
Contributor

mikeerickson commented Jun 24, 2020

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 :)

@madsem
Copy link

madsem commented Jun 24, 2020

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

Just spitballing here, might be possible.

@mikeerickson
Copy link
Contributor

@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.

@madsem
Copy link

madsem commented Jun 25, 2020

@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.

@mikeerickson
Copy link
Contributor

@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 🤓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants