Manually added files to priv are not copied to release

Following the excellent guide here:

I have put some css js and image files manually in priv/static because they didn’t work nicely with brunch. However they don’t end up in the release on the production server.

I haven’t been able to figure out why yet. Can anyone shed some light on this?

Thanks in advance.

Only manually added files don’t show up? Or no files show up? Are they anywhere in the release (like in lib/<your_app>-<version>/priv after you untar the release)?

1 Like

Are you using Application.app_dir(:myapp, "priv") or :code.priv_dir(:myapp) to access the files? Or are you just building a path by hand, like Path.join("priv", "foo"), because the latter may work under Mix, but the path is different in a release, so it won’t work the same way there. The first two approaches work in both Mix and releases, so I would always build paths that way.

2 Likes

I don’t think it’s to do with the way I’m building the paths. It looks like the files are not copied there, even though the stuff that’s not manually added to priv in development (stuff I put in assets), is there on the server (‘thumbs_up.jpg’ etc…). For example the css directory should contain several other files. It seems like distillery doesn’t copy from priv, but generates a new priv for each release - is this correct? It seems like I’m missing something very obvious…

Here is the directory structure on the server:

priv
├── gettext
│   ├── en
│   │   └── LC_MESSAGES
│   │       └── errors.po
│   └── errors.pot
├── repo
│   └── seeds.exs
└── static
    ├── cache_manifest.json
    ├── css
    │   ├── app-833cc7e8eeed7a7953c5a02e28130dbd.css
    │   ├── app-833cc7e8eeed7a7953c5a02e28130dbd.css.gz
    │   ├── app-8ceceec9edf5bdf25c4330689c495a9b.css
    │   ├── app-8ceceec9edf5bdf25c4330689c495a9b.css.gz
    │   ├── app.css
    │   └── app.css.gz
    ├── favicon-a8ca4e3a2bb8fea46a9ee9e102e7d3eb.ico
    ├── favicon.ico
    ├── images
    │   ├── ghi-c49d0ad79b3c75a639e495a121a7a4af.jpg
    │   ├── ghi.jpg
    │   ├── ghi-l-7aab776b12c01cb0c623c552b60241f7.jpg
    │   ├── ghi-l.jpg
    │   ├── abc-ccc502f1d8549c7e7affd55f659cbf0f.jpg
    │   ├── abc.jpg
    │   ├── abc-l-42b27719b42f001018997b25a5b5fa60.jpg
    │   ├── abc-l.jpg
    │   ├── phoenix-5bd99a0d17dd41bc9d9bf6840abcc089.png
    │   ├── phoenix.png
    │   ├── slides
    │   │   ├── drawing-690c2c57b882f6998e335c7d5be57141.jpg
    │   │   ├── drawing.jpg
    │   │   ├── notebook-caa0c2b9d2472b57d2e1e173494d39ae.jpg
    │   │   ├── notebook.jpg
    │   │   ├── notepad-83a27d89bdd7bfb3d39574e9a18cf7de.jpg
    │   │   ├── notepad.jpg
    │   │   ├── palm_up copy-afcd7c5dd1718350ae73d1f94bd1ac89.jpg
    │   │   ├── palm_up copy.jpg
    │   │   ├── thumbs_up-0df5af0769e5680c0546608844e87966.jpg
    │   │   └── thumbs_up.jpg
    │   ├── def-03aec875df0108a3c3860d486516d083.jpg
    │   ├── def.jpg
    │   ├── def-l-0a88094d7fd59bf6f97daa4986edc18a.jpg
    │   └── def-l.jpg
    ├── js
    │   ├── app-8f0317e89884de8b7b3a685928bee5e7.js
    │   ├── app-8f0317e89884de8b7b3a685928bee5e7.js.gz
    │   ├── app.js
    │   └── app.js.gz
    ├── robots-067185ba27a5d9139b10a759679045bf.txt
    ├── robots-067185ba27a5d9139b10a759679045bf.txt.gz
    ├── robots.txt
    └── robots.txt.gz

Distillery will copy everything in priv, always, whenever a release is generated via mix release. If something is not present there when you extract the tarball, it is either because those files were added/generated after the release was already packaged, or they were stripped out by something else.

I know edeliver extracts and rebuilds the tarball at some point, so it is possible the issue is there, but I’m not clear on what is present at the various stages of your app being built/deployed, so it may not be edeliver either. Perhaps a more thorough walkthrough of how you are building and deploying things, along with a description of when those files are added, will help identify the problem.

2 Likes