Skip to content
This repository was archived by the owner on Dec 24, 2025. It is now read-only.

Commit d689cd1

Browse files
committed
Update only applications that changed when deploying new versions
1 parent 45e3346 commit d689cd1

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/makina/applications.ex

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,35 @@ defmodule Makina.Applications do
113113
defp do_update(%Server{} = server, %Application{} = app) do
114114
IO.puts(" Updating \"#{app.name}\"")
115115

116-
with {:ok, _} <- remove_stale_app(server, app),
116+
with {:ok, :update} <- check_update_required(server, app),
117+
{:ok, _} <- remove_stale_app(server, app),
117118
{:ok, _} <- mark_app_as_stale(server, app),
118119
{:ok, _} <- do_deploy(server, app),
119120
{:ok, _} <- stop_stale_app(server, app) do
120121
{:ok, :updated}
122+
else
123+
{:ok, :no_update} ->
124+
IO.puts(" No update needed for \"#{app.name}\"")
125+
{:ok, :no_update}
126+
127+
error ->
128+
error
129+
end
130+
end
131+
132+
defp check_update_required(server, app) do
133+
case inspect_deployed_application(server, app) do
134+
{:ok, container} ->
135+
running_hash = get_in(container, ["Config", "Labels", "org.makina.app.hash"])
136+
137+
cond do
138+
is_nil(running_hash) -> {:error, :no_app}
139+
String.to_integer(running_hash) != app.__hash__ -> {:ok, :update}
140+
String.to_integer(running_hash) == app.__hash__ -> {:ok, :no_update}
141+
end
142+
143+
{:error, _} ->
144+
{:error, :no_app}
121145
end
122146
end
123147

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Makina.MixProject do
44
def project do
55
[
66
app: :makina,
7-
version: "0.1.17",
7+
version: "0.1.18",
88
elixir: "~> 1.18",
99
start_permanent: Mix.env() == :prod,
1010
deps: deps(),

0 commit comments

Comments
 (0)