bengro
Let’s assume I have a massive frontend codebase based on the Jam-stack. The existing backend will be replaced with Phoenix to leverage real-time features such as Sockets and Presence.
How would you deploy the frontend and the backend?
Would you deploy the frontend in the Erlang VM with some sort of webserver?
Would you deploy the backend in the Erlang VM, but the frontend in a “traditional” way (e.g. nginx)?
I appreciate any links to projects or opinions/thoughts.
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using.
We’re particularly inte...
New
I’m posting this in response to Jose’s recent tweet (Cr. link) :
People are sleeping on Elixir for a coding harness:
Hot-code swappi...
New
Hello,
I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
AcmeScript — Writing JS hooks as if I were still using Elixir
I’ve been having fun building a little something over the last few days: Ac...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #elixirconf-us
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
vincer
I make heavy use of a similar stack and here are some solutions I’ve come across:
Backend options (option to store frontend with backend):
Gigalixir
A platform-as-a-service for Elixir. Very easy to use and I believe they have a free tier.
Their docs point to this helpful sample repo that includes assets that are compiled with Webpack. You can choose to store frontend here or not. I didn’t end up using them as I didn’t like the Python dependency.
Render.com
A sort of platform-as-a-service for all frameworks. No free tier, but the prices are reasonable. You basically just need to provide a
build.shfile in your repo which handles building your app. If you wanted to store your frontend here, you would just need to add build instructions to thebuild.shfile. I tried their service and had no complaints, but in the end I found Kubernetes more flexible and easier for my use-case. I believe they use AWS or Google Cloud themselves.Kubernetes on Google and Digital Ocean
This is what I use these days for all my projects (all are Vue 3 + Vite + Elixir apps). It’s the most productive recipe for me at the moment. I prefer keeping frontend and backend together as it simplifies deployment and testing. This approach is more complicated, but more flexible. I use Nginx in this setup. I maintain the details of this recipe in this repo.
Frontend options
If you want to host your frontend separately there many many options for that.
Free options
Render.com and now Digital Ocean let you host a few static frontends for free. The prices are very low even after the free tier.
Otherwise, there’s obviously Vercel, Netlify and soon Cloudflare Pages and probably a bunch of others.
Additional notes on storing frontend with backend
When storing the frontend with the backend, the Phoenix app serves the frontend content and assets. This Phoenix app may optionally also be behind something like Nginx. When storing the frontend separately with one of the providers listed above, the different services handle the serving of frontend assets for you mostly.
bengro
Thanks for your reply! Some really good tips and links in there.
One question that is still not clear to me is how a project structure looks like that say has an API component and a fully-fletched single page app as part of the same project.
In that sense, I’m still asking myself:
From a developer experience as well as a deployment point of view, what is an established pattern for developing backends and frontends?
Does this make any sense? Sorry, these must be very dumb questions
vincer
I have tried a few different structures and the one I like best is the one seen in this
[folder](https://github.com/PotionApps/potionx/tree/main/packages/templates/src/project/potionx). Basically I keep all my Javascript apps in a folder calledfrontendin the same repository as the Elixir code and I serve the correct one based on the request’s domain or path. All requests go through the backend which routes the request to the right Javascript app. (Request → Elixir Backend → Controller → View → index.html containing the assets to a single page app)I don’t think there is an established way of separating the two sides. At least if there is one, I haven’t found it yet. It all comes down to productivity. I’ve found that keeping the frontend apps and the backend together is the most productive for me in terms of ease of testing and speed of deployments.
In terms of configuring the client-side routing, I usually have Phoenix serve the right assets through a view like the one here. You can then use something like Cloudflare to serve the assets via CDN automatically if you’re worried about performance.
Your questions are definitely not dumb and I think many of us are still trying to find the best approach. There’s probaby no setup is going to suit everyone perfectly. I think you have to choose something that is most productive and least error-prone for you. In my case, I found managing only one project much much more productive than managing two projects.
bengro
Super helpful, thank you. I completely agree regarding the benefits of a “mono-project” for e2e tests and deployment.
In addition to what you’re describing, I found this article also very helpful:
https://medium.com/@resir014/a-phoenix-react-initial-setup-that-actually-works-c943e48f1e9e
It was incredibly helpful tuning the webpack configuration.
I ended up creating an umbrella project and serving my single page application through Phoenix (as you described).
vincer
I moved from Webpack to Vite myself (build times are too painful with Webpack), but thank you for sharing.
Glad to hear it all worked out!