Created
September 4, 2023 13:37
-
-
Save BrunoMoraes-Z/cd9f3fb0648807ce072e81c2691b333c to your computer and use it in GitHub Desktop.
dockerfile - dart server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Specify the Dart SDK base image version using dart:<version> (ex: dart:2.12) | |
FROM dart:stable AS build | |
# 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 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/ | |
# COPY --from=build /app/data/ /app/data/ | |
COPY --from=build /app/public/ /app/public/ | |
# Start server. | |
EXPOSE 8080 | |
CMD ["/app/bin/server"] | |
# cmd /c "docker build -t service . & docker run -d -p 8080:8080 service" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment