FROM openfaas/classic-watchdog:0.3.1 as watchdog FROM dart:3.6.0 AS build # Allows you to add additional packages via build-arg ARG ADDITIONAL_PACKAGE RUN apt-get update -qy \ && apt-get install -qy ca-certificates ${ADDITIONAL_PACKAGE} --no-install-recommends \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog RUN chmod +x /usr/bin/fwatchdog # # Add non root user # RUN addgroup --system app && adduser --system --group app # RUN mkdir -p /home/app # WORKDIR /home/app # COPY bin /home/app/bin # COPY pubspec.yaml . # RUN chown -R app /home/app # COPY function function # RUN pub get # RUN pub get --offline # WORKDIR /home/app/function/ # RUN pub get && pub get --offline # RUN chown -R app /home/app # USER app # Resolve app dependencies. WORKDIR /app 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/bin/server /app/bin/ ENV fprocess="/app/bin/server" EXPOSE 8080 HEALTHCHECK --interval=3s CMD [ -e /tmp/.lock ] || exit 1 CMD ["fwatchdog"]