Edeliver not working after switching to Phoenix 1.3

edeliver
phoenix
#1

Hi, I recently got distillery and edeliver working with a Phoenix 1.2 app, but I’m getting errors running the following with a Phoenix 1.3 app using:

mix edeliver build release production --verbose

Everything works up until the following point:

-----> Running phoenix.digest
npm WARN saveError ENOENT: no such file or directory, open '/tmp/edeliver/myonepointthreetestapp/builds/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/tmp/edeliver/myonepointthreetestapp/builds/package.json'
npm WARN builds No description
npm WARN builds No repository field.
npm WARN builds No README data
npm WARN builds No license field.

up to date in 0.201s
bash: line 10: ./node_modules/brunch/bin/brunch: No such file or directory

Anyone have any idea why this is happening?

0 Likes

#2

You need to tell edeliver that it has to run npm install and brunch from within the assets directory, from your error messages I do assume, it tries at the project root currently.

0 Likes

#3

Thanks Nobbz,

How would I change this edeliver .deliver/config file to do that?

APP="myonepointthreetestapp"

BUILD_HOST="xxx.xx.xx.xx"
BUILD_USER="freebsd"
BUILD_AT="/tmp/edeliver/$APP/builds"

#RELEASE_DIR="/tmp/edeliver/$APP/builds/_build/prod/rel/$APP"

# prevent re-installing node modules; this defaults to "."
GIT_CLEAN_PATHS="_build rel priv/static"

STAGING_HOSTS="xxx.xx.xx.xxx"
STAGING_USER="freebsd"
TEST_AT="/home/freebsd/staging"

PRODUCTION_HOSTS="xxx.xx.xx.xx"
PRODUCTION_USER="freebsd"
DELIVER_TO="/home/freebsd/www"

# For *Phoenix* projects, symlink prod.secret.exs to our tmp source
pre_erlang_get_and_update_deps() {
  local _prod_secret_path="/home/freebsd/prod.secret.exs"
  if [ "$TARGET_MIX_ENV" = "prod" ]; then
    __sync_remote "
      ln -sfn '$_prod_secret_path' '$BUILD_AT/config/prod.secret.exs'
    "
  fi
}

pre_erlang_clean_compile() {
  status "Running phoenix.digest" # log output prepended with "----->"
  __sync_remote " # runs the commands on the build host
    # [ -f ~/.profile ] && source ~/.profile # load profile (optional)
    source ~/.profile
    # echo \$PATH # check if rbenv is in the path
    set -e # fail if any command fails (recommended)
    cd '$BUILD_AT' # enter the build directory on the build host (required)
    # prepare something
    mkdir -p priv/static # required by the phoenix.digest task
    npm install

    ./node_modules/brunch/bin/brunch build --production

    # run your custom task
    APP='$APP' MIX_ENV='$TARGET_MIX_ENV' $MIX_CMD phoenix.digest $SILENCE
  "
}
0 Likes

#4

I’m totally not sure, since I do not use edeliver at all, none of my projects got thus far :wink:

But I’d guess you need to do roughly this diff:

 # prepare something
 mkdir -p priv/static # required by the phoenix.digest task
+pushd assets
 npm install
 
 ./node_modules/brunch/bin/brunch build --production
+popd
 
 # run your custom task
3 Likes

A Beginner's Guide To Deployment with Edeliver and Distillery
#5

You need to cd '$BUILD_AT/assets' before the any npm install and brunch commands.

However, the other commands such as mkdir -p priv/static and the line with phoenix.digest still need to be run with cd '$BUILD_AT'.

2 Likes

#6

I think my patch accomplishes exactly this, doesn’t it?

0 Likes

#7

Yes that should work if your shell supports it. I haven’t tried it though!

0 Likes

#8

Thanks, this has partially fixed the problem - here’s the output with a new error relating to phoenix.digest

08:00:50 - info: compiling
08:00:50 - info: compiled 6 files into 2 files, copied 3 in 4.5 sec
17 Aug 08:00:50 - info: [copycat] copied 6 files
** (Mix) The task "phoenix.digest" could not be found. Did you mean "phoenix.new"?

Any thoughts?

0 Likes

#9

Thanks NobbZ!

0 Likes

#10

It looks from that output as if the phoenix.digest command is not being run from '$BUILD_AT'. Are you sure you cd'd back to it?

0 Likes

#11

popds output is missing from the shown log, so probably not.

0 Likes

#12

Thanks Chris, I’m not sure if this is what you and NobbZ mean, but this worked for the build:

pre_erlang_clean_compile() {
  status "Running phoenix.digest" # log output prepended with "----->"
  __sync_remote " # runs the commands on the build host
    # [ -f ~/.profile ] && source ~/.profile # load profile (optional)
    source ~/.profile
    # echo \$PATH # check if rbenv is in the path
    set -e # fail if any command fails (recommended)
    cd '$BUILD_AT' # enter the build directory on the build host (required)
    # prepare something
    mkdir -p priv/static # required by the phoenix.digest task
    cd '$BUILD_AT/assets'
    npm install

    ./node_modules/brunch/bin/brunch build --production

    # run your custom task
    cd '$BUILD_AT'
    APP='$APP' MIX_ENV='$TARGET_MIX_ENV' $MIX_CMD phoenix.digest $SILENCE
  "
}

I have deployed and started it -0

however, the site is showing a 404, whereas it didn’t before.

0 Likes

#13

Thats basically the same as mine but cding instead of using the the directory-stack.

In most cases I do prefer to use the directory stack, its easier to recover the initial working directory then.


Is the 404 from your application or from an upstream (reverse) proxy? Do you get it for any route or for static assets only? Does it work locally when you just run mix phx.server?


PS: You should also change your script to call mix phx.digest instead of mix.phoenix.digest, the phoenix-tasks may be removed completely with 1.4. Its better to be prepared.

1 Like

#14

Thanks, I tried your directory stack commands, but perhaps because I’m using freebsd they didn’t work? I’m a bit of a novice at freebsd but prefer it, so am yet to learn those commands, so used the cd command instead.

(Yes, I must update the script to use mix phx.digest instead of mix.phoenix.digest, thanks.)

The site works at localhost:4000, and yes the production server is behind a nginx reverse proxy, which hasn’t changed in config since running the Phoenix 1.2 build of the site.

I just tired to ping the production server using mix edeliver ping production, oddly it shows this:

-----> pinging production servers

production node:

  user    : freebsd
  host    : xxx.xx.xx.xx
  path    : /home/freebsd/www
  response: Node 'myonepointthreetestapp@127.0.0.1' not responding to pings.

I guess there’s something obviously wrong in a config file somewhere?

This is the relevant part of my config/prod.exs

config :myonepointthreetestapp, MyonepointthreetestappWeb.Endpoint,
  http: [port: 8080],
  url: [host: "myappurl.tld", port: 80],
  cache_static_manifest: "priv/static/cache_manifest.json"

Swapping out the made up url and test app project, the only thing that’s different in the 1.3 config above from the 1.2 one that worked is the last line. The 1.2 looks like this:

cache_static_manifest: "priv/static/manifest.json"

But I imagine that’s not the config issue?

0 Likes

#15

Availability of pushd/popd massively depend on the shell you use. Most of the time I simply do assume a recent bash which has them built-in. But it seems as if BSD based systems do use something else as drop-in replacement for sh (or sh directly, which doesn’t have them as well).

Sorry for this.

0 Likes

#16

If you’ve tried to start the app but it’s not responding to pings, I would first suggest examining the logs and looking for a crash dump.

Look for erl_crash.dump and in var/log/ inside the release directory in /home/freebsd/www.

0 Likes

#17

Thanks Chris, I’ve got it building, deploying, starting… and now it’s pinging… but still not showing on the server, which is strange, especially as I haven’t changed the nginx config.

Would I have to change the root dir in nginx for Phoenix 1.3?

0 Likes

#18

Hello all I am new with edeliver, I am usingPhoenix 1.2, I try with cd '$BUILD_AT/assets' but I got the error cd: /tmp/edeliver/kyks_production/builds/assets: No such file or directory any ideas?

0 Likes

#19

Add mkdir -p '$BUILD_AT/assets' before cd '$BUILD_AT/assets'

0 Likes