Closed bradcypert closed 2 years ago
You may need to add an ENV HOMEDIR=
to your Dockerfile to get dart pub get
to drop the files into the right place.
Here's a Dockerfile that I know works running an app in the VM.
@cpswan I will try this out soon! thank you so much!
I finally fully understood what my issue was. My issue was that I was using a volume that was my entire app folder and it was pushing .dart_tool/ into the container as well, which was referencing paths on my host machine.
My docker file ultimately ended up like this:
FROM dart:2.17
ENV HOMEDIR=/manudac
WORKDIR /app
COPY . .
RUN rm /app/pubspec.lock
RUN rm -rf .dart_tool
RUN dart pub get --no-offline
RUN dart pub update
EXPOSE 4040
CMD ["dart", "run", "lib/app.dart"]
I can probably clean that up a bit, but at least its no longer a blocker. Thanks again @cpswan ! :)
This may be out of the scope of this project and if so, my apologies, but I'm trying to setup Dart with Docker in such a way that I can use the Dart VM instead of an AoT executable. I want to do this to support local development as if I was running
dart run
.I'm so very close to having it working but Im not sure what I need to change to get it to successfully run!
My issue seems to be stemming from errors that look like this:
Namely, any and all of my dependencies are not being found when running inside of the container. It looks like you can set the pub cache directory via an environment variable, and I had some success setting that to my local directory, but then running the application outside of docker becomes a pain. I have those dependencies installed locally and I can run my app by running dart run lib/app.dart as long as I'm not running the app through docker (but this isnt ideal).
I've tried running the AoT version shared in this project but a library that im using uses Dart Mirrors, too.
Any tips?
Thanks and files are attached for context.
Here's my dockerfile:
and my compose: