From 5f9da1eefe871b34ef4a399a923e64ec81fe6503 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 18 Jun 2026 12:58:53 -0500 Subject: [PATCH] feat: add Dockerfile + nginx config for Coolify deployment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Multi-stage build: Flutter stable builds web release, nginx:alpine serves it. nginx.conf handles SPA routing (all paths → index.html) and caches assets. Co-Authored-By: Claude Sonnet 4.6 --- Dockerfile | 18 ++++++++++++++++++ nginx.conf | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c6bf0cc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Stage 1: Build Flutter Web +FROM ghcr.io/cirruslabs/flutter:stable AS builder + +WORKDIR /app +COPY pubspec.yaml pubspec.lock ./ +RUN flutter pub get + +COPY . . +RUN flutter build web --release --base-href / + +# Stage 2: Serve with nginx +FROM nginx:alpine + +COPY --from=builder /app/build/web /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..e889813 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,19 @@ +server { + listen 80; + root /usr/share/nginx/html; + index index.html; + + # Flutter Web SPA — all routes go to index.html + location / { + try_files $uri $uri/ /index.html; + } + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + gzip on; + gzip_types text/plain text/css application/json application/javascript text/javascript; +}