From 1bff2062fb4afd7057ff0d0e6e2273f6e9d7a429 Mon Sep 17 00:00:00 2001 From: ImBenji Date: Sun, 29 Mar 2026 15:19:34 +0100 Subject: [PATCH] Remove port mapping from Docker Compose configuration --- Dockerfile | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index ac895b2..3137e70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,43 @@ -# Build stage -FROM cirrusci/flutter:latest AS builder +# syntax=docker/dockerfile:1.7 + +# Stage 1: Build the Flutter web app +FROM ghcr.io/cirruslabs/flutter:stable AS build WORKDIR /app -COPY pubspec.* ./ -COPY lib ./lib -COPY web ./web -COPY assets ./assets +ENV PUB_CACHE=/root/.pub-cache -RUN flutter pub get -RUN flutter build web --release +# Copy pubspec files and get dependencies +COPY pubspec.yaml pubspec.lock ./ +COPY packages/perfetto_trace/pubspec.yaml packages/perfetto_trace/pubspec.yaml +RUN --mount=type=cache,target=/root/.pub-cache \ + flutter pub get -# Serve stage +# Copy the rest of the app +COPY . . + +# Build web app +RUN --mount=type=cache,target=/root/.pub-cache \ + flutter build web --release + +# Stage 2: Serve with nginx FROM nginx:alpine +ARG PUBLISHED_AT -COPY --from=builder /app/build/web /usr/share/nginx/html +# Copy the built web app from build stage +COPY --from=build /app/build/web /usr/share/nginx/html +# Copy runtime update manifest outside Flutter asset pre-cache. +COPY --from=build /app/app-version.json /usr/share/nginx/html/app-version.json -COPY nginx.conf /etc/nginx/nginx.conf +# Fill published_at at image build time (UTC), unless explicitly provided. +RUN set -eu; \ + published_at="${PUBLISHED_AT:-$(date -u +%Y-%m-%dT%H:%M:%SZ)}"; \ + sed "s|__BUILD_PUBLISHED_AT__|${published_at}|g" /usr/share/nginx/html/app-version.json > /tmp/app-version.json; \ + mv /tmp/app-version.json /usr/share/nginx/html/app-version.json +# Copy custom nginx config +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Expose port EXPOSE 80 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"]