Repository: phoenixframework/phoenix
Pull request #4688 (2022-02-15 16:08:48)

Don't generate asset handling in Docker when directory doesn't exist
Checks if the `assets` directory is present and adds asset handling to the Dockerfile if needed.
Not sure if this is the desired direction.

Ref: #4669


Patch:
diff --git a/guides/introduction/community.md b/guides/introduction/community.md
index e26192c00..fb5ef58cf 100644
--- a/guides/introduction/community.md
+++ b/guides/introduction/community.md
@@ -38,6 +38,8 @@ There are a number of places to connect with community members at all experience
   * [Phoenix LiveView Free Course (by The Pragmatic Studio - 2020)](https://pragmaticstudio.com/courses/phoenix-liveview)
 
   * [Groxio LiveView: Self Study Program (by Bruce Tate - 2020)](https://grox.io/language/liveview/course)
+  
+  * [Alchemist Camp: Learn Elixir and Phoenix by building (2018-2022)](https://alchemist.camp/episodes)
 
   * [The Complete Elixir and Phoenix Bootcamp Master Functional Programming Techniques with Elixir and Phoenix while Learning to Build Compelling Web Applications (by Stephen Grider - 2017)](https://www.udemy.com/the-complete-elixir-and-phoenix-bootcamp-and-tutorial/)
 
diff --git a/installer/lib/mix/tasks/phx.new.ex b/installer/lib/mix/tasks/phx.new.ex
index 10320f6a6..b8f737cde 100644
--- a/installer/lib/mix/tasks/phx.new.ex
+++ b/installer/lib/mix/tasks/phx.new.ex
@@ -216,7 +216,7 @@ defmodule Mix.Tasks.Phx.New do
   end
 
   defp rebar_available? do
-    Mix.Rebar.rebar_cmd(:rebar) && Mix.Rebar.rebar_cmd(:rebar3)
+    Mix.Rebar.rebar_cmd(:rebar3)
   end
 
   defp print_missing_steps(steps) do
diff --git a/installer/templates/phx_single/config/runtime.exs b/installer/templates/phx_single/config/runtime.exs
index d1ad49f85..4b55834f1 100644
--- a/installer/templates/phx_single/config/runtime.exs
+++ b/installer/templates/phx_single/config/runtime.exs
@@ -29,7 +29,7 @@ if config_env() == :prod do
   port = String.to_integer(System.get_env("PORT") || "4000")
 
   config :<%= @app_name %>, <%= @endpoint_module %>,
-    url: [host: host, port: 443],
+    url: [host: host, port: 443, scheme: "https"],
     http: [
       # Enable IPv6 and bind on all interfaces.
       # Set it to  {0, 0, 0, 0, 0, 0, 0, 1} for local network only access.
diff --git a/lib/mix/tasks/phx.gen.release.ex b/lib/mix/tasks/phx.gen.release.ex
index 21afa6346..f3ad6e828 100644
--- a/lib/mix/tasks/phx.gen.release.ex
+++ b/lib/mix/tasks/phx.gen.release.ex
@@ -51,7 +51,8 @@ defmodule Mix.Tasks.Phx.Gen.Release do
       app_namespace: app_namespace,
       otp_app: app,
       elixir_vsn: System.version(),
-      otp_vsn: otp_vsn()
+      otp_vsn: otp_vsn(),
+      assets_dir_exists?: File.dir?("assets")
     ]
 
     Mix.Phoenix.copy_from(paths(), "priv/templates/phx.gen.release", binding, [
diff --git a/priv/templates/phx.gen.release/Dockerfile.eex b/priv/templates/phx.gen.release/Dockerfile.eex
index 0f2472a95..3727bdb5c 100644
--- a/priv/templates/phx.gen.release/Dockerfile.eex
+++ b/priv/templates/phx.gen.release/Dockerfile.eex
@@ -45,12 +45,12 @@ RUN mix deps.compile
 COPY priv priv
 
 COPY lib lib
-
+<%= if assets_dir_exists? do %>
 COPY assets assets
 
 # compile assets
 RUN mix assets.deploy
-
+<% end %>
 # Compile the release
 RUN mix compile
 


Test patch:
diff --git a/installer/test/phx_new_test.exs b/installer/test/phx_new_test.exs
index ffbbd002e..1928d8648 100644
--- a/installer/test/phx_new_test.exs
+++ b/installer/test/phx_new_test.exs
@@ -153,7 +153,7 @@ defmodule Mix.Tasks.Phx.NewTest do
         end
         """
         assert file =~ ~S[host = System.get_env("PHX_HOST") || "example.com"]
-        assert file =~ ~S|url: [host: host, port: 443],|
+        assert file =~ ~S|url: [host: host, port: 443, scheme: "https"],|
       end
       assert_file "phx_blog/config/test.exs", ~R/database: "phx_blog_test#\{System.get_env\("MIX_TEST_PARTITION"\)\}"/
       assert_file "phx_blog/lib/phx_blog/repo.ex", ~r"defmodule PhxBlog.Repo"
diff --git a/test/mix/tasks/phx.gen.release_test.exs b/test/mix/tasks/phx.gen.release_test.exs
index 3f205b4c5..5f162b74c 100644
--- a/test/mix/tasks/phx.gen.release_test.exs
+++ b/test/mix/tasks/phx.gen.release_test.exs
@@ -114,4 +114,27 @@ defmodule Mix.Tasks.Phx.Gen.ReleaseTest do
       assert_receive {:mix_shell, :info, ["\nYour application is ready to be deployed" <> _]}
     end)
   end
+
+  test "generates release and docker files with assets dir", config do
+    in_tmp_project(config.test, fn ->
+      File.mkdir_p!("assets")
+      Gen.Release.run(["--docker"])
+
+      assert_file("Dockerfile", fn file ->
+        assert file =~ ~S|COPY assets assets|
+        assert file =~ ~S|mix assets.deploy|
+      end)
+    end)
+  end
+
+  test "generates release and docker files without assets dir", config do
+    in_tmp_project(config.test, fn ->
+      Gen.Release.run(["--docker"])
+
+      assert_file("Dockerfile", fn file ->
+        refute file =~ ~S|COPY assets assets|
+        refute file =~ ~S|mix assets.deploy|
+      end)
+    end)
+  end
 end