generateDockerfileDev method
Generate development Dockerfile
Implementation
Future<void> generateDockerfileDev() async {
if (!config.createServer) return;
info('Generating Dockerfile-dev...');
final String content =
'''
# Development Dockerfile for ${config.serverPackageName}
# Includes Flutter SDK for debugging
#
# Build context: the server package directory (e.g. ${config.serverPackageName}/).
# Oracular copies the sibling models package into this directory before
# `docker build` so `${config.modelsPackageName}/` is available at the
# root of the context.
FROM ubuntu:22.04
# Install dependencies
# `flutter build linux --release` requires the full Flutter Linux desktop
# toolchain (clang, cmake, ninja-build, pkg-config, libgtk-3-dev,
# liblzma-dev, libstdc++-12-dev). The runtime libraries (libgtk-3-0,
# libblkid1, liblzma5) come along automatically as transitive deps.
RUN apt-get update && apt-get install -y \\
curl \\
git \\
unzip \\
xz-utils \\
zip \\
libglu1-mesa \\
libgtk-3-0 \\
libblkid1 \\
liblzma5 \\
clang \\
cmake \\
ninja-build \\
pkg-config \\
libgtk-3-dev \\
liblzma-dev \\
libstdc++-12-dev \\
&& rm -rf /var/lib/apt/lists/*
# Install Flutter
RUN git clone https://github.com/flutter/flutter.git /flutter
ENV PATH="/flutter/bin:\$PATH"
RUN git config --global --add safe.directory /flutter
RUN flutter doctor
RUN flutter config --enable-linux-desktop
# Copy the models package alongside /app so the relative path
# `../${config.modelsPackageName}` in pubspec.yaml resolves correctly.
COPY ${config.modelsPackageName}/ /${config.modelsPackageName}/
# Copy server source (everything in the build context) into /app.
WORKDIR /app
COPY . /app/
# Get dependencies
RUN flutter pub get
# Copy service account key (lives at the root of the build context).
COPY *.json ./
# Expose port
EXPOSE 8080
# Run the server in development mode
CMD ["flutter", "run", "-d", "linux"]
''';
final File file2 = File(p.join(serverPath, 'Dockerfile-dev'));
await file2.writeAsString(content);
success('Generated: ${config.serverPackageName}/Dockerfile-dev');
}