I have been banging my head against a wall for the last couple of days because of a really weird problem I’m having in production.
I have a very simple Phoenix app that lets an admin user upload an image when creating a “note”. I’m using
arc-ecto to handle the file uploads. Everything works great in development. I’m able to upload the images without issues, and I can see them on the “notes” page.
However, when the app is running in production, I am able to upload the images without errors, but Phoenix is giving me a 404 when trying to fetch the images.
I already added the
Plug.Static declaration to may
endpoint.ex file, which is why I am able to see the images in dev, but no matter what I try in production, I always get a 404.
I have this in my
endpoint.ex file. I already tried replacing
Path.expand("./uploads") with the full path of where the files are when in production, and no luck.
plug Plug.Static, at: "/uploads", from: Path.expand("./uploads/"), gzip: false
I know Elixir has access to this folder in production, because after uploading the images, they are there.
I’m using Distillery to create the release for production, and I’m deploying the app as a Docker image using
docker-compose. I already made sure that the destination of the uploaded files is mounted as a volume on the Docker image, so that they don’t get destroyed after each deploy.
What could possibly be happening here?
I’m really close to just giving up trying to get
Plug.Static to work in prod, and just
Base64 encode the images and inlining them in the HTML file.
Any help, or guidance you can give me is greatly appreciated!