Nvim

Nvim

Is there a Phoenix VPS Deployment Guide?

I can’t find any comprehensive guide on deploying Phoenix on a VPS with PostgreSQL, Nginx, Ubuntu 18.04. Anybody knows?

First 10 of 37 Posts! Switch mode

lpil

lpil

Creator of Gleam

Hey @Nvim! What are you looking for that isn’t in the official guide? Introduction to Deployment — Phoenix v1.8.8

I’d note that you probably don’t need Nginx as the Cowboy webserver used by Phoenix is plenty fast enough for serving static assets etc. :slight_smile:

Nvim

Nvim

@Ipil Thanks I’ll check this out just not familiar how Cowboy performs.

lpil

lpil

Creator of Gleam

If you have any problems post here. Good luck!

outlog

outlog

also:

and

Kurisu

Kurisu

Ok I’m taking this opportunity. ^^
I have an umbrella project that contains 2 web apps (frontend and admin).
In the official deployment guide there is no specific path for an umbrella project.
So in my case do I have to deploy the 2 phoenix web apps separetely or as a whole one project.
I just want to be sure if I will be doing the things the right way.
In my understanding it is better to deploy them separetely. Is it ok?

Also in my case, since the 2 web apps will be running on the same VPS, I think I will need something like HAProxy (unless I want to keep some :PORT in the admin app urls for example).
Am I right? If I am, do you think NGINX is a better choice than HAProxy for that?

lpil

lpil

Creator of Gleam

Hey!

I’m a big fan of keeping everything as simple as possible so instead of effectively serving two applications on two ports I would mount one application on the other, possibly by using Phoenix’s forward macro to redirect requests to the /admin path to the admin app’s router module Phoenix.Router — Phoenix v1.8.8.
This way you’re only deploying one web application and the admin app gets requests under /admin for example.

Exadra37

Exadra37

If you want to go with running your app in Docker, then a better choice is Traefik

The Cloud Native Edge Router

A reverse proxy / load balancer that’s easy, dynamic, automatic, fast, full-featured, open source, production proven, provides metrics, and integrates with every major cluster technology… No wonder it’s so popular!

The best of all in this Traefik setup is that the generation and renewal of LetsEncrypt certificates is done on the fly.

An example docker compose file:

version: "2.1"

services:

  phoenix:
    image: phoenix/app
    build: ./docker
    restart: always
    env_file: .env
    environment:
      - MIX_ENV=prod
    networks:
      - traefik
      - default
    command: "elixir -S mix phx.server"
    volumes:
      - "$PWD:/home/elixir/workspace"
    labels:
      - "traefik.enable=true"
      - "traefik.backend=elixir-app-name"
      - "traefik.docker.network=traefik"
      - "traefik.port=4000"
      - "traefik.frontend.rule=Host:example.com"

networks:
  traefik:
external: true

NOTE: This file is not tested and is an adaptation of a current one for a Python server

To setup Traefik on the Host just follow the docs about LetsEncrypt & Docker.

shanesveller

shanesveller

I would not under any circumstances describe traefik as a “better” tool than nginx or haproxy - particularly for a single host. It trades away at least a decade worth of hardening and optimizing for a mildly easier configuration format, and even that is subjective. Nor should anyone advocate using docker-compose for serious deployments.

Both nginx/haproxy would serve well at splitting one port number to two applications by some combination of host name and/or path, and will otherwise stay out of your way very well. It’s still trivial to automate LetsEncrypt with either one. I would ultimately still aim for @lpil’s suggestion of keeping to a single deployment if possible, though, and you’ll find Cowboy very capable in its own right.

Nvim

Nvim

Any benchmark of Cowboy vs Nginx?

danschultzer

danschultzer

Pow Core Team

I wrote a guide on how to do a CI build/deploy using ansible: https://dreamconception.com/tech/phoenix-automated-build-and-deploy-made-simple/

We’ve been using this setup to automate deploys to digital ocean. Here’s the sample repo: GitHub - danschultzer/ansible-phoenix-build: Sample app with full build and deploy setup of a Phoenix app using ansible · GitHub

It doesn’t cover provisioning, but we use ansible for that too (nginx, mariadb, letsencrypt, etc).

Last Post!

AlchemistCamp

AlchemistCamp

Use @OvermindDL1’s pid_file.ex for that. Here’s my setup: Elixir learning: How to generate a Pid-File for an Elixir app

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
saveman71
Hello ! We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
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
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement