Docker anvil-server and dependencies

I am trying to run my app on the latest docker version of anvil-server.

I have downloaded the dependencies and placed them in pier directories, but I am getting the following error when I run the container:

The app you requested could not be loaded.
This app may be misconfigured. The following error occurred:

App dependency not found

Here is the directory structure:
±-anvil.works/
| ±-MyApp/
| ±-anvil-extras/
| ±-material-3-theme

anvil.yaml:

allow_embedding: false
correct_dependency_ids: {dep_lin1x4oec0ytd: 4UK6WHQ6UX7AKELK, dep_mh1r0kj22geoes: C6ZZPAPN4YYF5NVJ}
dependencies:
- config: {}
  dep_id: dep_lin1x4oec0ytd
  resolution_hints: {app_id: 4UK6WHQ6UX7AKELK, name: Material 3 Theme, package_name: m3}
  version: {version_tag: v1.2.1}
- dep_id: dep_mh1r0kj22geoes
  resolution_hints: {app_id: C6ZZPAPN4YYF5NVJ, name: Anvil Extras, package_name: anvil_extras}
  version: {version_tag: v3.1.0}
name: Librarian 1.0.1
native_deps:
  head_html: |-
    <script>
    var lastScrollTop = {};
    function getScrollPosition(selector) {
      lastScrollTop[selector] = $(selector).scrollTop();
    }
    function restoreScrollPosition(selector) {
      $(selector).scrollTop(lastScrollTop[selector]);
    }
    </script>
package_name: M3_CoreLight_Librarian
runtime_options:
  client_version: '3'
  server_spec: {base: python310-standard}
  server_version: python3-full
  version: 3
services:
- client_config: {}
  server_config: {}
  source: /runtime/services/tables.yml
startup: {module: Main, type: form}
startup_form: null

Is there a parameter I need to pass to the container indicating where to find the dependencies?

Thank you!

1 Like

Does anyone have any help on this one? Am I missing something that is obvious?

Sounds like you just need to include the code for your dependencies and point to it.

There is information on this in the anvil-runtime github repo here dep-id

The App Server looks for dependencies in the parent directory of the app (that is, dependency apps should be checked out next to the main app directory, not inside it).

dep-id:
  "MAGTM7NPDRPPUAWY": "MyLibrary"
  "LUBRMCXK3R4FTTH3": "CustomComponent1"

I am having the same issue.

Placing a dependency directory next to the main folder, does not help, something needs to be done with dep_id.

You are right @augustas.volbekas, you need to use dep-id in the config file to let Anvil know where each dependency lives. This is a map between the opaque id and the directory containing the dependency.

So, for @dave2 it would look something like this:

dep-id:
  "4UK6WHQ6UX7AKELK": "material-3-theme"
  "C6ZZPAPN4YYF5NVJ": "anvil-extras"

Thank you so much for the reply. I have created a file config-file.yaml and placed it in the MyApp directory. Here is a copy of that file.

dep-id:
  "4UK6WHQ6UX7AKELK": "material-3-theme"
  "C6ZZPAPN4YYF5NVJ": "anvil-extras"

From the MyApp directory, I run docker with:

docker run -v /code/container/anvil.works/librarian-1.0.1:/apps/MainApp -p 3030:3030 anvilworks/anvil-app-server --config-file config-file.yaml

And I receive the following error:

[ERROR anvil.app-server.run] #error {
 :cause config-file.yaml (No such file or directory)
 :via
 [{:type java.io.FileNotFoundException
   :message config-file.yaml (No such file or directory)
   :at [java.io.FileInputStream open0 FileInputStream.java -2]}]
 :trace
 [[java.io.FileInputStream open0 FileInputStream.java -2]
  [java.io.FileInputStream open FileInputStream.java 195]
  [java.io.FileInputStream <init> FileInputStream.java 138]
  [clojure.java.io$fn__11617 invokeStatic io.clj 229]
  [clojure.java.io$fn__11617 invoke io.clj 229]
  [clojure.java.io$fn__11569$G__11523__11576 invoke io.clj 69]
  [clojure.java.io$fn__11629 invokeStatic io.clj 258]
  [clojure.java.io$fn__11629 invoke io.clj 254]
  [clojure.java.io$fn__11569$G__11523__11576 invoke io.clj 69]
  [clojure.java.io$fn__11591 invokeStatic io.clj 165]
  [clojure.java.io$fn__11591 invoke io.clj 165]
  [clojure.java.io$fn__11530$G__11519__11537 invoke io.clj 69]
  [clojure.java.io$reader invokeStatic io.clj 102]
  [clojure.java.io$reader doInvoke io.clj 86]
  [clojure.lang.RestFn invoke RestFn.java 410]
  [clojure.lang.AFn applyToHelper AFn.java 154]
  [clojure.lang.RestFn applyTo RestFn.java 132]
  [clojure.core$apply invokeStatic core.clj 669]
  [clojure.core$slurp invokeStatic core.clj 7010]
  [clojure.core$slurp doInvoke core.clj 7010]
  [clojure.lang.RestFn invoke RestFn.java 410]
  [anvil.app_server.run$handle_basic_config invokeStatic run.clj 146]
  [anvil.app_server.run$handle_basic_config invoke run.clj 142]
  [anvil.app_server.run$_main invokeStatic run.clj 416]
  [anvil.app_server.run$_main doInvoke run.clj 414]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [anvil.app_server.run main nil -1]]}
Found Anvil App Server JAR in package directory

So from the error, it can’t find my config-file.yaml. Using the full directory path failed as well.

If I remove the --config-file from docker I get the following:

[INFO  anvil.app-server.postgres] Launching embedded Postgres database. Find Postgres daemon logs in the ' /anvil-data ' directory.
[INFO  anvil.app-server.postgres] Initialising embedded Postgres database...
Database is uninitialised. Setting up Anvil database from scratch...
Setup complete.
Database now at "2024-02-12-session-expiry"
[WARN  anvil.app-server.tables] This app does not have a 'db_schema' configuration, so we are not setting up the database.
[INFO  anvil.core.server] HTTP Server running on port 3030
[INFO  anvil.app-server.run] SMTP Server running on port 25
[INFO  anvil.app-server.run] App URL:  http://localhost:3030
[INFO  anvil.app-server.dispatch] Launching built-in downlink...
[INFO  anvil.executors.downlink] Downlink client connected with spec {:runtime "python3-full", :session_id "g7sl4H58hjONpSN84gbd"}
[WARN  anvil.runtime.app-data] Cannot depend on dependency before other checks MainApp dep_lin1x4oec0ytd {:ref "refs/tags/v1.2.1"}: 
[WARN  anvil.runtime.app-data] Cannot depend on dependency before other checks MainApp dep_mh1r0kj22geoes {:ref "refs/tags/v3.1.0"}: 
[WARN  anvil.runtime.app-data] Cannot depend on dependency before other checks MainApp dep_lin1x4oec0ytd {:ref "refs/tags/v1.2.1"}: 
[WARN  anvil.runtime.app-data] Cannot depend on dependency before other checks MainApp dep_mh1r0kj22geoes {:ref "refs/tags/v3.1.0"}: 

Which makes since as it does not know where to find them.

What am I missing?

Check out this post, this helped me a lot: