Files
krow-worker-app/Dockerfile
2026-09-28 19:55:33 +05:30

50 lines
1.7 KiB
Docker

# Flutter web build, served as static files by nginx.
#
# Dokploy builds this repo with its Dockerfile provider, so the image does the
# whole job: install the Flutter SDK, compile the web bundle, hand the output to
# a web server. Nothing from the build stage survives into the final image but
# build/web.
#
# The SDK comes from the official archive at a pinned version rather than from a
# `flutter:stable` image: those images trail the real stable channel, and the
# one tagged stable ships a Dart older than the SDK floor in pubspec.yaml, so
# `pub get` refuses to resolve. Keep FLUTTER_VERSION in step with the toolchain
# the app is developed against.
FROM debian:bookworm-slim AS build
ARG FLUTTER_VERSION=3.44.9
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates curl git unzip xz-utils \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${FLUTTER_VERSION}-stable.tar.xz" \
| tar -xJ -C /opt
ENV PATH="/opt/flutter/bin:${PATH}"
# The SDK is a git checkout owned by a different user than the one building, so
# without this every flutter command dies on git's dubious-ownership check.
RUN git config --global --add safe.directory /opt/flutter \
&& flutter config --disable-analytics \
&& flutter precache --web
WORKDIR /app
# Dependencies resolve from the pubspec alone, so copying it first keeps the
# `pub get` layer cached across source-only changes.
COPY pubspec.yaml pubspec.lock ./
RUN flutter pub get
COPY . .
RUN flutter build web --release
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/build/web /usr/share/nginx/html
EXPOSE 80