Background
I am creating a simple Phoenix umbrella application to run on a client’s Windows 11 machine and my objective is to have something like an .exe
file for running said application.
Code
I am creating the application and releasing it using Elixir’s normal release procedure, using the commands:
mix phx.new demo --umbrella --no-ecto --no-dashboard --no-gettext --no-mailer
cd demo_umbrella
mix deps.get
# set MIX_ENV=prod before doing this last step!
mix release demo
For those of you curious, this is the releases
function I am using inside my mix.exs
:
defp releases,
do: [
demo: [
applications: [
demo_web: :permanent,
runtime_tools: :permanent
],
include_executables_for: [:windows]
]
]
Now, this basic setup will create a .bat
file: _build\prod\rel\demo\bin\demo.bat
that I can start and stop via the following commands: _build\prod\rel\demo\bin\demo {start | stop}
.
Problems & Research
Users that know programming can simply open a terminal in Windows, type _build\prod\rel\demo\bin\demo start
and the application will launch (accessible via localhost:4000).
But users normally don’t have such knowledge. So I want something as close to an .exe
file as possible.
I have tried using Bakeware:
And its spiritual successor, Burrito:
Unfortunately, both fail to work for Windows 11. This leads me to try the shortcut approach.
Here I create Windows shortcut to demo.bat
and I specify in the target path the commands:
Which in this case will be %windir%\system32\cmd.exe /c start "" "%CD%\demo.bat" start
Now, all is fine and dandy, but there is a problem:
- the console always appears.
Questions
So this leaves me to the following questions:
- How do I prevent the console from showing?
- Does
demo.bat
include the erlang VM and the elixir version needed to run the application? Or do I need to have those installed in the client’s machine ? - I am under the impression that Elixir releases are supposed to include everything needed (https://elixir-lang.org/getting-started/mix-otp/config-and-releases.html):
A release is a self-contained directory that consists of your application code, all of its dependencies, plus the whole Erlang Virtual Machine (VM) and runtime. Once a release is assembled, it can be packaged and deployed to a target as long as the target runs on the same operating system (OS) distribution and version as the machine that assembled the release.
, but in case this bat file does not include everything, how do I fix this?