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

Commit 524bce3

Browse files
committed
Remove the concept of standalone application as it is redundant
"standalone" application were supposed to be those apps that one wants to run alongside others but they may not need to necessarely interact with each other. Ultimately I came to the conclusion that they were no different than a normal "app" and was only making things more confused, therefore I removed it.
1 parent 8746f45 commit 524bce3

File tree

11 files changed

+85
-134
lines changed

11 files changed

+85
-134
lines changed

.formatter.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
locals_without_parens = [
44
server: 1,
5-
standalone: 1,
65
app: 2,
76
from_docker_image: 1,
87
docker_registry: 1,

lib/makina/applications.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ defmodule Makina.Applications do
1717
Connection is established before triggering applications deployment
1818
and disconnection happens when all applications have been deployed.
1919
"""
20-
def deploy_standalone_applications(servers, applications)
20+
def deploy_applications(servers, applications)
2121
when is_list(servers) and is_list(applications) do
2222
for server <- servers do
2323
Servers.with_connection!(server, fn s ->
@@ -27,13 +27,13 @@ defmodule Makina.Applications do
2727
end
2828

2929
@doc """
30-
Stops all provided standalone applications in all servers
30+
Stops all provided applications in all servers
3131
3232
`servers` should be a list of servers to stop applications into.
3333
3434
Servers and applications are processed sequentially.
3535
"""
36-
def stop_standalone_applications(servers, applications)
36+
def stop_applications(servers, applications)
3737
when is_list(servers) and is_list(applications) do
3838
for server <- servers do
3939
Servers.with_connection!(server, fn s ->
@@ -43,13 +43,13 @@ defmodule Makina.Applications do
4343
end
4444

4545
@doc """
46-
Removes all provided standalone applications in all servers
46+
Removes all provided applications in all servers
4747
4848
`servers` should be a list of servers to stop applications into.
4949
5050
Servers and applications are processed sequentially.
5151
"""
52-
def remove_standalone_applications(servers, applications)
52+
def remove_applications(servers, applications)
5353
when is_list(servers) and is_list(applications) do
5454
for server <- servers do
5555
Servers.with_connection!(server, fn s ->

lib/makina/cli.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ defmodule Makina.Cli do
99
init: Commands.Init,
1010
server: Commands.Server,
1111
debug: Commands.Debug,
12-
standalone: Commands.Standalone
12+
app: Commands.App
1313
}
1414
end
1515

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule Makina.Cli.Commands.Standalone do
1+
defmodule Makina.Cli.Commands.App do
22
@behaviour Makina.Cli.Command
33

44
import Makina.Cli.Utils
@@ -8,26 +8,29 @@ defmodule Makina.Cli.Commands.Standalone do
88

99
@sub_commands ~w[deploy stop remove]a
1010

11-
def name(), do: "standalone"
11+
def name(), do: "app"
1212

1313
def short_description(),
14-
do: "Manage standalone applications defined in the Makinafile"
14+
do: "Manage applications defined in the Makinafile"
1515

1616
def help,
1717
do: """
1818
Makina
19-
Standalone applications management command
19+
Applications management command
2020
21-
Manages all standalone applications found in the current Makinafile.
21+
Manages all applications found in the current Makinafile.
2222
2323
Usage:
24-
makina standalone <SUB COMMAND> [OPTIONS]
24+
makina app <SUB COMMAND> [OPTIONS]
2525
2626
Sub-commands:
27-
deploy Deploys all standalone applications defined in the Makinafile.
27+
deploy Deploys all applications defined in the Makinafile.
28+
stop Stops all applications.
29+
remove Removes containers of applications from servers.
2830
2931
Options:
30-
* --file - The path to a Makinafile, if not provided the command will look for it in the current folder.
32+
* --app Specifies which app to apply the command to.
33+
* --file The path to a Makinafile, if not provided the command will look for it in the current folder.
3134
"""
3235

3336
def exec(arguments, options) do
@@ -45,7 +48,7 @@ defmodule Makina.Cli.Commands.Standalone do
4548
|> fetch_context()
4649

4750
servers = ctx.servers
48-
apps = filter_apps_from_options(ctx.standalone_applications, options)
51+
apps = filter_apps_from_options(ctx.applications, options)
4952
deployment_result = do_deploy(servers, apps)
5053

5154
case deployment_errors?(deployment_result) do
@@ -67,7 +70,7 @@ defmodule Makina.Cli.Commands.Standalone do
6770
|> fetch_context()
6871

6972
servers = ctx.servers
70-
apps = filter_apps_from_options(ctx.standalone_applications, options)
73+
apps = filter_apps_from_options(ctx.applications, options)
7174
deployment_result = do_stop(servers, apps)
7275

7376
case deployment_errors?(deployment_result) do
@@ -89,7 +92,7 @@ defmodule Makina.Cli.Commands.Standalone do
8992
|> fetch_context()
9093

9194
servers = ctx.servers
92-
apps = filter_apps_from_options(ctx.standalone_applications, options)
95+
apps = filter_apps_from_options(ctx.applications, options)
9396
deployment_result = do_remove(servers, apps)
9497

9598
case deployment_errors?(deployment_result) do
@@ -118,7 +121,7 @@ defmodule Makina.Cli.Commands.Standalone do
118121
end
119122

120123
defp do_deploy(servers, apps) do
121-
Applications.deploy_standalone_applications(servers, apps)
124+
Applications.deploy_applications(servers, apps)
122125
end
123126

124127
defp do_stop(_servers, []) do
@@ -128,7 +131,7 @@ defmodule Makina.Cli.Commands.Standalone do
128131
end
129132

130133
defp do_stop(servers, apps) when is_list(apps) do
131-
Applications.stop_standalone_applications(servers, apps)
134+
Applications.stop_applications(servers, apps)
132135
end
133136

134137
defp do_remove(_servers, []) do
@@ -138,7 +141,7 @@ defmodule Makina.Cli.Commands.Standalone do
138141
end
139142

140143
defp do_remove(servers, apps) when is_list(apps) do
141-
Applications.remove_standalone_applications(servers, apps)
144+
Applications.remove_applications(servers, apps)
142145
end
143146

144147
defp filter_apps_from_options(apps, options) do

lib/makina/dsl.ex

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,11 @@ defmodule Makina.DSL do
6060
end
6161
end
6262

63-
@doc """
64-
Defines a block of applications that are standalone
65-
66-
Applications defined inside this block are deployed, or removed, in the remote server
67-
independently from others, this means that dependencies cannot be defined between these.
68-
69-
Can be useful if you want to deploy a standalone application that doesn't have other moving pieces.
70-
71-
For cases where the application might require other services (for example a webapp + a database) then `stack` is the correct option.
72-
"""
73-
defmacro standalone(do: block) do
74-
quote do
75-
unquote(set_scope(:standalone))
76-
unquote(block)
77-
end
78-
end
79-
8063
@app_opts [name: [type: :string, required: true]]
8164

8265
@doc """
8366
Defines an application
84-
Within this block you can configure the application that you want to deploy, can be used within a `standalone` block or `stack` block.
67+
Within this block you can configure the application that you want to deploy.
8568
8669
Depending on the context some configurations might not be available
8770
"""
@@ -103,7 +86,7 @@ defmodule Makina.DSL do
10386

10487
unquote(block)
10588

106-
@standalone_applications @current_application
89+
@applications @current_application
10790
Module.delete_attribute(__MODULE__, :current_application)
10891

10992
unquote(pop_scope(2))
@@ -181,7 +164,7 @@ defmodule Makina.DSL do
181164
quote do
182165
Module.register_attribute(__MODULE__, :scope, accumulate: true)
183166
Module.register_attribute(__MODULE__, :servers, accumulate: true)
184-
Module.register_attribute(__MODULE__, :standalone_applications, accumulate: true)
167+
Module.register_attribute(__MODULE__, :applications, accumulate: true)
185168
Module.register_attribute(__MODULE__, :proxy_config, accumulate: false)
186169
end
187170
end
@@ -193,7 +176,7 @@ defmodule Makina.DSL do
193176
id: @context_id,
194177
servers: @servers,
195178
proxy_config: @proxy_config,
196-
standalone_applications: @standalone_applications
179+
applications: @applications
197180
)
198181
end
199182
end

lib/makina/models/context.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ defmodule Makina.Models.Context do
77
alias Makina.Models.ProxyConfig
88

99
@derive JSON.Encoder
10-
defstruct id: nil, servers: [], standalone_applications: [], proxy_config: nil
10+
defstruct id: nil, servers: [], applications: [], proxy_config: nil
1111

1212
@type t() :: %Context{
1313
id: nonempty_binary(),
1414
servers: list(),
15-
standalone_applications: list(),
15+
applications: list(),
1616
proxy_config: ProxyConfig.t()
1717
}
1818

lib/makina/server_initializer.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ defmodule Makina.ServerInitializer do
3131
reverse_proxy(ctx.proxy_config)
3232
]
3333

34-
Applications.deploy_standalone_applications([server], system_applications)
34+
Applications.deploy_applications([server], system_applications)
3535

3636
server
3737
end

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.18",
7+
version: "0.1.20",
88
elixir: "~> 1.18",
99
start_permanent: Mix.env() == :prod,
1010
deps: deps(),

test/makina/applications_test.exs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# defmodule Makina.ApplicationsTest do
2+
# use ExUnit.Case, async: true
3+
4+
# import Mox
5+
6+
# alias Makina.Applications
7+
# alias Makina.Models.Server
8+
# alias Makina.Models.Application
9+
10+
# describe "deploy_applications/2" do
11+
# test "launces commands to deploy a list of applications on all servers" do
12+
# expect(TestRemoteCommandExecutor, :execute, fn
13+
# %{cmd: "docker run " <> rest} ->
14+
# assert rest =~ "test_"
15+
16+
# dbg(rest)
17+
18+
# {:ok, %{}}
19+
# end)
20+
21+
# servers = [
22+
# Server.new(host: "example1.com", user: "foo"),
23+
# Server.new(host: "example1.com", user: "foo")
24+
# ]
25+
26+
# apps = [get_dummy_application(), get_dummy_application()]
27+
28+
# Applications.deploy_applications(servers, apps)
29+
30+
# verify!()
31+
# end
32+
# end
33+
34+
# defp get_dummy_application() do
35+
# Application.new(name: "test_#{DateTime.utc_now()}")
36+
# |> Application.set_docker_image(name: "foo")
37+
# end
38+
# end

0 commit comments

Comments
 (0)