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

Having trouble building a PHP app #94

Closed
1zaak opened this Issue Dec 31, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@1zaak
Copy link

1zaak commented Dec 31, 2017

Hi @githubsaturn,

I am deploying a PHP app but once deployed, it is showing 503 error. The contents of my captain-definition are as below:

{
    "schemaVersion" :1 ,
    "dockerfileLines" :[
                         "FROM php:7.1.1-alpine",
                         "RUN apk update && apk add --no-cache git curl",
                         "RUN mkdir -p /usr/local/bin/ && curl -s -o installer.php \"https://getcomposer.org/installer\" && php installer.php --install-dir=/usr/local/bin --filename=composer && rm -f installer.php && composer global require \"hirak/prestissimo:^0.3\"",
                         "RUN mkdir -p /var/www/html",
                         "COPY ./src/ /var/www/html/",
                         "RUN composer install -d /var/www/html/"
                     ]
}

This is the last iteration of the file. I have tried a lot of configurations actually, but none of them work. Tried digging in the Nginx configs and saw that it is mainly doing this and it's not configured to run PHP files for captain-definition with dockerfileLines config, although it works fine with PHP templateId.

Even running composer install locally, commiting all the vendor files in git and just use "templateId" :"php/7.1.1" would not work because I need to set env vars.

I'm sure I missed something here. Do I need to setup PHP-FPM for the Alpine image in the container? Do I need to explicitly tell Nginx that the root web folder is /var/www/html, and if so, how?

If none of the above is the problem, can you point me in the right direction to solve this issue once and for all?

Thanks for the great repo though. Hell of a project!

@sidharthv96

This comment has been minimized.

Copy link
Contributor

sidharthv96 commented Dec 31, 2017

Hi,
You will have to have a CMD which actually runs the php server inside your container and exposes it via port 80 to nginx.

"CMD [ "php", "-S", "[::]:80", "-t", "/var/www/html" ]",
"EXPOSE 80",

Here is a link to oneclick app deploy script of adminer.
Go through this, might be helpful

@1zaak

This comment has been minimized.

Copy link

1zaak commented Dec 31, 2017

Awesome! Thanks @sidharthv96 !

@1zaak 1zaak closed this Dec 31, 2017

@tuefekci

This comment has been minimized.

Copy link

tuefekci commented Jul 9, 2018

Warning
This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.
http://php.net/manual/en/features.commandline.webserver.php

I know this is a old issue, but i got here from the manual so be careful if you need realibility of your application check out some of the php images and extend them to your needs.

@githubsaturn

This comment has been minimized.

Copy link
Collaborator

githubsaturn commented Jul 9, 2018

Good catch. Note that the built-in image for PHP on CaptainDuckDuck uses the Apache variant of the image, which serves as a powerful webserver:

https://github.com/githubsaturn/captainduckduck/blob/0b39c1a14e853692eb0dd6c775ba6103ab057434/app-backend/src/user/TemplateHelper.js#L96

You can, for example, use FROM php:7.2.7-apache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment