Compiling and building a release locally, then copying it to a server

Up to this point I’ve been using edeliver. Now I want to build and release an app via mix.

If I build a release on a local computer:

MIX_ENV=prod mix release --overwrite 

and then simply copy this file

_build/prod/rel/my_app/bin/my_app

to a remote server and launch:

_build/prod/rel/my_app/bin/my_app background

will everything work as intended?

Provided that the environment on a server has been set up.

Also, I’m on Mac and will build a release on it. Will it work on a Linux server?

No, you have to use exactly the same environment.

Not completely true.

After creating the release you’ll have the following folder

_build/prod/rel/my_app/bin/my_app

Then you have to copy all the files and folders under

build/prod/rel

to your remote server.

To create a release I copy my source files to a build server which has erlang, elixir, and nodejs installed. This build server is actually a virtual machine in VirtualBox in my development computer.

Then I generate the release on the build server and finally copy the release to the production server.

The production server does not need to have erlang, elixir or nodejs installed since the release contains all the necessary files to run your app.

Interesting.

Can OS-es on a built server and production one differ? MacOS ↔ Linux, or MacOS ↔ FreeBsd

Only if you don’t include erts in the release and install the exact same version of erlang on the production system. And NIFs need to be taken care of. Generally it’s easier to setup docker or some over vm to mimic production then trying to align production with another OS on the build server.