ospaarmann

ospaarmann

Asset URLs don't include digest when deploying to Heroku using Releases

When I deploy a phoenix app to Heroku, the paths of static assets in the html are missing the digest. So instead of src="js/admin-62123d5990c2dec10fc43f27f068113c.js" I just get a plain src="js/admin.js" for MyRoutes.static_path(@conn, "/js/admin.js")

When I run the app locally with MIX_ENV=prod mix phx.server the paths are correct. So I assume it has something to do with using releases for deployment.

I use these buildpacks (in this order):

  1. https://buildpack-registry.s3.amazonaws.com/buildpacks/hashnuke/elixir.tgz
  2. GitHub - gjaldon/heroku-buildpack-phoenix-static: A Heroku buildpack for building Phoenix's static assets · GitHub
  3. GitHub - chrismcg/heroku-buildpack-elixir-mix-release: A Heroku buildpack for use with Elixir 1.9+ releases · GitHub

I can see in the build logs that the digest is working. I can also see the digested assets in the file system and I can access them via http. But the darn paths are not correct. The file cache_manifest.json is also generated and I set it in my endpoint configuration in prod.exs

config :my_app, MyAppWeb.Endpoint,
  http: [:inet6, port: String.to_integer(System.get_env("PORT") || "4000")],
  url: [host: host, port: String.to_integer(System.get_env("URL_PORT") || "80")],
  # be aware that if using mix ```release``` statics will be served from
  # _build/prod/rel/kurabu_app/lib/kurabu_app-0.1.0/priv/static
  static_url: [host: host, port: String.to_integer(System.get_env("URL_PORT") || "80")],
  cache_static_manifest: "priv/static/cache_manifest.json",
  secret_key_base: secret_key_base,
  server: true,
  check_origin: false

I am not sure what the reason is and how to proceed from here. I am thankful for any hints to point me in the right direction.

For completion:

elixir_buildpack.config

# Erlang version
erlang_version=22.3.4.12

# Elixir version
elixir_version=1.10.4

# Always rebuild from scratch on every deploy?
always_rebuild=false

# A command to run right after compiling the app
hook_post_compile="./heroku/hook_run_migrations.sh"

# Set the path the app is run from
runtime_path=/app

phoenix_static_buildpack.config

# Clean out cache contents from previous deploys
clean_cache=true

# We can change the filename for the compile script with this option
compile="compile"

# We can set the version of Node to use for the app here
node_version=12.14.1

# We can set the version of Yarn to use for the app here
yarn_version=1.21.1

# Remove node and node_modules directory to keep slug size down if it is not needed.
remove_node=false

# We can change phoenix mix namespace tasks. E.g. `phoenix` for phoenix < 1.3 support.
phoenix_ex=phx

compile

cd $phoenix_dir
mix compile
npm run deploy --prefix ./assets
mix "${phoenix_ex}.digest"

Marked As Solved

ospaarmann

ospaarmann

Well, never mind. I was an idiot and didn’t correctly configure the endpoint in releases.exs because I somehow thought prod.exs was the relevant file. And there the values for static_url and cache_static_manifest were wrong…

Conclusion: If a problem seems very hard to understand, look for an easy solution you might have missed.

Where Next?

Popular in Questions Top

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
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New

Other popular topics Top

New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31265 143
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 48342 226
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement