Replies: 4 comments 3 replies
-
The general recommendation is to not run multiple processes in the same container. This isn't buildpack-specific advice but general advice on using containers. When you add multiple processes you complicate things, like scaling and failure handling. It also mixes concerns. Nginx is your proxy/gateway, that's part of the networking layer, not your app. If you stuff all that into one container, then you're making your deployment less flexible. If for example, you want to switch to another proxy/gateway, then you need to rebuild your containers and deploy everything again. If you have them separate, you swap out your proxy/gateway, and the backend never even knows. What I'd suggest you try is two builds. First, build an nginx container with your nginx.conf file. It should be trivial to get that container to build, but you might need to adjust your nginx config if it assumes your backend server is running on localhost. The nginx buildpack supports env variable substitution in your config file, so if you make the backend target an env variable it can make your container very flexible. Exactly what you pass in as the value for that env variable will depend on your runtime orchestration of the containers. If for example, you are using Docker Compose, you can pass in the service name of your backend service and send requests that way. Essentially you need to see what your container orchestrator provides in the way of service discovery and use that. Then do a second build with just your Python backend. The Paketo Python buildpack should handle building that correctly. Maybe someone from @paketo-buildpacks/python-maintainers can comment, but I believe it should support gunicorn/uwsgi deployments. As far as the PHP setup goes, that's a little different. The primary way you deploy PHP is with PHP-FPM, but PHP-FPM is not a web server. It's a separate protocol so we pair either Nginx or HTTPD with it because some container orchestration systems expect HTTP traffic. If you wanted to do something similar to that with Python, you'd be looking at a custom buildpack. It could reuse most of the existing Python buildpacks, but you'd need a custom buildpack that would integrate Nginx and add process types to start up both processes. Remember how I said that running multiple processes in the same container is tricky? That's going to come into play with the process types. You'd probably need to include some sort of process manager to make sure that you handle different failure scenarios correctly. For example, what if Nginx dies but your app does not? or vice versa? If you don't have your error handling set up to terminate the container, then you can get into a situation where your containers are up and "healthy" but not healthy. Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply :) I know about the general recommendation, that's a container's theory, but I have a practical use case. It depends on how do you look at complete application and how your infrastructure looks like 😎
|
Beta Was this translation helpful? Give feedback.
-
Regarding custom buildpack I was thinking about packaging multirun as a buildpack to provide entrypoint that calls Python + NGINX, but my client does preffer this way and I'm looking for simpler options. |
Beta Was this translation helpful? Give feedback.
-
I dont feel offended at all :), thanks so much for your response. The good
practices you mentioned could be perfect for other readers which may
possibly dont know that, so thats ok :))
I think way with apt (package manager at all) may be difficult due to air
gapped environment in my case, but the Procfile approach could be useful.
Regarding custom buildpack I was thinking to avoid using Go. I noticed that
example on buildpacks.io on how to build own buildpack is in Bash. I think
installing Multirun should be simple enough, then I could use Procfile for
the rest. My client may not be ready to learn new language I think
currently, they have everything in Python :)
Is writting a buildpack fully in Bash and using it with Paketo builder
possible? :)
niedz., 10 gru 2023, 01:30 użytkownik Daniel Mikusa <
***@***.***> napisał:
… You could certainly make a custom buildpack to install multirun. You
might also consider using the Apt Buildpack
<https://github.com/dmikusa/apt-buildpack> assuming that multirun is
available as a package or Deb file. That would save some work and prevent
you from needing a custom buildpack to install it.
You could also use a Procfile if you don't want a custom buildpack just
to set the process types. The Procfile buildpack
<https://github.com/paketo-buildpacks/procfile>, basically takes a
Procfile and turns the commands in that file into process types.
If you include a Procfile with your app and use the Apt buildpack to
install multirun or some other process manager, maybe you can get by
without any custom buildpacks. Not 100% sure though cause you still need
something to pull in Nginx.
If you go the route of a custom buildpack, and haven't already, check out
the PHP Start Buildpack <https://github.com/paketo-buildpacks/php-start>.
The README there explains the buildplan we use in PHP to pull everything
together pretty well. That's also the glue that pulls everything together,
so you might be able to swipe some code from there.
—
Reply to this email directly, view it on GitHub
<#230 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC25M7KOVO6OALW6W3MADDYIT7CTAVCNFSM6AAAAABAKTFD7GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM3TQMBZGUYDC>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Hi,
I need to run nginx & django/gunicorn/uwsgi to serve both static files and Python backend.
The team says they are having complex redirection rules in NGINX and don't want to change it to something else.
I already used NGINX buildpack and know how to use it, I have also used cpython and nodejs buildpacks, but I don't know how to make two entrypoints working together.
I'm also a PHP developer and I noticed there is a php-start buildpack which runs NGINX and PHP-FPM, but I noticed it is not reusable.
Is there a way to run at least two processes at once?
Beta Was this translation helpful? Give feedback.
All reactions