"mix compile" run on VPS from a local machine won't work

I have a simple way to deploy a Phoenix/Elixir which is: login onto a server ssh, compile a project via mix, build a release and restart a project. Everything works well. However, once I’ve tried to automate the process, I’ve discovered:


# Step a: Connect to the server via SSH
ssh aaa@example.com << 'EOF'
  cd /usr/local/web/pr1
  git pull origin master -f
  if [ -z "$(git diff --check)" ]; then
    echo "No conflicts detected"
    echo "Conflicts detected, please resolve before continuing"
    exit 1

  export $(cat config/.env.prod | xargs)

  # ok
  echo "**debug #0"
  # (!) this won't pass this command
  mix compile --force

  # no errors, but this will never get executed
  echo "**debug #1"

  # Step g: Check for errors
  if [ $? -eq 0 ]; then
    echo "No errors detected"
    # .........

    echo "done"
    echo "Errors occurred during custom tool execution"
    exit 1

A script will always stop after the command mix compile has run. No errors, no compilation ones either! I’d do it manually and it’d work!

As if there was a signalt the mix compile --force would send to the terminal or ssh connection exit the process.

What’s the matter?

Wouldn’t it be easier to just create a file there with all commands, chmod a+x and run it? I do something like that, I have a local compile file, I copy it, and run it through a script.


What is it in my question if not one?

Your script isn’t stored on the client or the server machine, you’re providing it inline. That’s the difference.

Where is the script, within which this inline script is, stored then?

And show me a way to embed “ssh user@server << EOF …(commands) …” which wouldn’t require an inline script