ospaarmann

ospaarmann

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"

Showing Posts 1 to 1

ospaarmann

ospaarmann OP

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.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
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
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews