Skip to content

Commit

Permalink
phx.gen.release: Add explicit mix assets.setup step (#5865)
Browse files Browse the repository at this point in the history
This step will install Tailwind and esbuild earlier and the container
layer shall be cached depending only on dependencies and config (where
Tailwind and esbuild tool versions are actually defined).

Code changes in priv, lib and assets shall not cause those tools to be
re-downloaded and installed.
  • Loading branch information
rhcarvalho committed Jul 10, 2024
1 parent 6787722 commit 5c87b96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion priv/templates/phx.gen.release/Dockerfile.eex
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ RUN mkdir config
# to be re-compiled.
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile

<%= if assets_dir_exists? do %>
RUN mix assets.setup
<% end %>
COPY priv priv

COPY lib lib
Expand Down
6 changes: 4 additions & 2 deletions test/mix/tasks/phx.gen.release_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ defmodule Mix.Tasks.Phx.Gen.ReleaseTest do
Gen.Release.run(["--docker"])

assert_file("Dockerfile", fn file ->
assert file =~ ~S|RUN mix assets.setup|
assert file =~ ~S|COPY assets assets|
assert file =~ ~S|mix assets.deploy|
assert file =~ ~S|RUN mix assets.deploy|
end)
end)
end
Expand All @@ -134,8 +135,9 @@ defmodule Mix.Tasks.Phx.Gen.ReleaseTest do
Gen.Release.run(["--docker"])

assert_file("Dockerfile", fn file ->
refute file =~ ~S|RUN mix assets.setup|
refute file =~ ~S|COPY assets assets|
refute file =~ ~S|mix assets.deploy|
refute file =~ ~S|RUN mix assets.deploy|
end)
end)
end
Expand Down

0 comments on commit 5c87b96

Please sign in to comment.