New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot resolve local dependencies from mono repo in Cloud Build docker image creation #253
Comments
Hi @blaueeiner! Just to clarify - you're aware you can switch to a git dependency before deploying but you want to keep the path dependency and copy over during the build? |
@nickmeinhold Yes I am aware that I can use a git dependency. Ideally I would like to keep the path. Yesterday I came to at least one solution for now that looks like this: I use I would appreciate to here about different solutions since I think mine is not that ideal. |
I have a rather convoluted solution to this problem too, I have a build script that copies the local project to Here is my Dockerfile: FROM dart:stable AS build
# Resolve app dependencies.
WORKDIR /app/os_cloud_functions
COPY temp/os_core/. /app/os_core
COPY pubspec.* ./
RUN dart pub get
# Copy app source code and AOT compile it.
COPY . .
# Ensure packages are still up-to-date if anything has changed
RUN dart pub get --offline
RUN dart pub run build_runner build --delete-conflicting-outputs
RUN dart compile exe bin/server.dart -o bin/server
# Build minimal serving image from AOT-compiled `/server` and required system
# libraries and configuration files stored in `/runtime/` from the build stage.
FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/os_cloud_functions/bin/server /app/os_cloud_functions/bin/
# Start server.
EXPOSE 8080
CMD ["/app/os_cloud_functions/bin/server"] |
Here's our solution - simply copy our local packages (in the ################
FROM google/dart:2.12
WORKDIR /dart_packages
COPY /dart_packages /dart_packages
WORKDIR /app
COPY /cb_serverless_functions/pubspec.yaml /app/pubspec.yaml
RUN dart pub get
COPY /cb_serverless_functions .
RUN dart pub get --offline
RUN dart pub run build_runner build --delete-conflicting-outputs
RUN dart compile exe bin/server.dart -o bin/server
########################
FROM subfuzion/dart:slim
COPY --from=0 /app/bin/server /app/bin/server
EXPOSE 8080
ENTRYPOINT ["/app/bin/server"] Then in your steps:
# Build the container image
- name: "gcr.io/cloud-builders/docker"
args:
[
"build",
"-t",
"gcr.io/$PROJECT_ID/cb_serverless_functions",
"-f",
"cb_serverless_functions/Dockerfile",
".",
] Then just make sure this runs from the root of your repository and not in your directory with the cloud functions. The |
@blaueeiner – are you unblocked here? |
@kevmoo Yes thx :) |
I am using functions-framwork-dart in a mono repo. It has its own dedicated project. I am sharing code between projects by using other projects which include the shared code. I am referencing the project as a dependency like this in the pubspec.yaml of the functions project:
Locally everything can be resolved properly but as soon as I deploy with
gcloud beta run deploy
it fails executing the docker file.I assume I need to also upload the dependency project folders. But how to do this? And how to then specify the Dockerfile path?
The text was updated successfully, but these errors were encountered: