maz

maz

Phoenix as simple webserver

We are making a web site which will be static content at first, but would require content updates of course. Essentially a marketing page. So I don’t foresee templating nor routes being required in the near future. Someday it’s possible that we’d need a webapp though so is it possible to have Phoenix serve pages like a very simple web server? Or would it be better just to make a simple elixir app that has Cowboy as a dependency instead for now? Can my colleague simply drop files in the right spot and no need to maintain any sort of cache?

First Post!

adrianrl

adrianrl

I’d say go for a static website generator (Gatsby, Jekyll, Next.js, Nuxt.js…), in other words, take a look to the JAMstack. Very simple, you just have to write HTML, CSS, JavaScript and Markdown, and if at some point you need something more dynamic, just create an API in Phoenix and fetch the data from your app.

Most Liked

maz

maz

So I finally settled on using nginx to serve static files. Cowboy with Plug is powerful but is serious overkill for a static site, from some investigation. I used:

https://github.com/alfredfrancis/minimal-nginx-web-server-docker

and tweaked the docker-compose.yml to suit my purposes:

version: '3'
services:
  nginx:
    build: image/
    ports:
    - "8080:80"
    volumes:
    - ./www/:/www-data/
    restart: always
    labels:
    - "traefik.frontend.rule=Host:****.app"
    - "traefik.frontend.entryPoints=http,https"
networks:
  default:
    external:
      name: web

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement