ubient / laravel-vapor-action

Run Laravel Vapor commands directly from Github Actions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues with composer extensions

atymic opened this issue · comments

Our project requires some extensions be installed which are missing in this action. You also can't customise the PHP version.

I was wondering if you'd come across this before?

Hi, thank you for your question and apologies for my somewhat slow reply.

I have ran into the scenario you provided, and the short answer is that you'd need to make some not-so straight forward changes to the Dockerfile in order to change the PHP version. Adding your own extensions would mean making adjustments as well, but would be significantly easier.

While I understand this might come as a disappointment, I hope you understand that I attempt to target the latest stable PHP and Laravel version currently released, which I believe most people run without any additional PHP extensions.

That said, let me get into what you'd need to do:

First of all, you'd need to fork this repository, and set up your project as described in the README.
The only real difference here is that you'd need to change the following in the Action you configure:

-   - uses: ubient/laravel-vapor-action@master
+   - uses: user/your-forked-repository@branch

After you've done that, you can start tuning the Dockerfile of your forked repository, and 'attempt' to deploy in order to see whether the changes you've made are getting you closer to a successful deployment.

Regarding just adding PHP extensions, without changing the PHP version, this is fairly straight forward. Just add the following line (including your extensions, space-separated) to the Dockerfile.
Here's an example:

RUN docker-php-ext-install mysqli mysqlnd pdo pdo_mysql zip

Regarding changing the PHP version, that would be more difficult, as this action uses the latest stable composer version (1.9.1) which in turn relies on the latest stable php version. (7.3.11)

Since that repository is out of our control, theres two ways you could go (to my knowledge):

  • Forking the composer docker repository as well, modifying that to depend on your PHP version and then depending the Dockerfile in your forked version of this repository onto that Dockerfile (I wouldn't recommend this)
  • Update the Dockerfile in your forked version of this repository, and to make it depend on the Dockerfile of the PHP version you need (instead of composer's), following by steps to install composer yourself, basically replicating the behaviour the official composer Dockerfile has within your own Dockerfile, with the difference being it being targeted to your specific PHP version.

While the 2nd option would result in a 'larger' Dockerfile, I believe this is the best solution of the two. It would end up looking something like this:

- FROM composer:latest
+ FROM php:5.6-alpine

+ RUN set -eux; \
+  apk add --no-cache --virtual .composer-rundeps \
+    bash \
+    coreutils \
+    git \
+ ... (etc. etc., you get the idea)

LABEL repository="https://github.com/ubient/laravel-vapor-action"
LABEL homepage="https://github.com/ubient/laravel-vapor-action"

As far as doing both of these things, well, you probably already guessed it: You're going to need a combination of the two things above.

I hope this answers your question and can help you towards solving your problem.
Let me know if you have any other questions.

Thanks for the super in depth response!

I'm actually on the latest laravel and PHP (6 & 7.3) but I need the bcmath extension add (it's required by laravel nova).

Since it's part of the official requirements for laravel, I think it would be ok to have it in this build? I'll make a PR.
https://laravel.com/docs/6.x#server-requirements

I ended up just using this action, and running a composer global install for vapor:
https://github.com/shivammathur/setup-php/

I did however run into an issue where it would get stuck on the migration step (I have no idea why).

PR here:
#2

Makes sense. Thank you!

As for the migration issue, I’m not entirely sure. I’ll see if I can replicate it later.

Yea, I have no idea why it happens. Waiting for a response from vapor support, there are no logs :(

I'll try with this again now it's got the extensions installed.

Alright, so, I noticed that that PR (#2) apparently broke the build and fixed it in #3.

Let me know if your deployment works now (it does here), and if so, feel free to close this issue.

My bad, sorry about that. Testing now!

Same Issue :(

I think the problem is on vapor's end (in the cli or on their server).

Re; the fix, it does work (has bcmath) but building the container seems to take > 1.5mins. I assume this can be cached, but after reading the docs I can't figure it out.

Alright, I’ve made a separate issue (#7) for this since this is more of a “nice to have” and doesn’t fit the scope of this extension issue.

In addition, since you indicated that the problem is fixed, I’ll close this issue so others don’t get scared off by seeing it remain in an open state in the overview list. If I’m mistaken and the issue isn’t fixed after all, let me know and i‘ll re-open it!

Hi! I realize this issue has been closed for a while now, but I figured I'd still post an update in case anyone ever lands here via (for example) Google:

This is now supported in a fairly easy-to-use/copy-paste friendly way: https://github.com/ubient/laravel-vapor-action#advanced-usage

Builds still take a while, but should be significantly faster with this method. Enjoy!