From f542a999797996a4e713ee3a74e7a8cce5bef1e0 Mon Sep 17 00:00:00 2001 From: mammad-xero Date: Sun, 31 Aug 2025 16:53:52 +0330 Subject: [PATCH] Add CI/CD pipeline and Docker setup for Flutter web application --- .drone.yml | 36 ++++++++++++++++++++++++++++++ Dockerfile | 55 ++++++++++++++++++++++++++++++++++++++++++++++ configs/nginx.conf | 20 +++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100644 configs/nginx.conf diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..7864242 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,36 @@ +################################################################################ +# development +################################################################################ + +kind: pipeline +type: docker +name: (dev) build flutter web and push to artifactory + +steps: + - name: tag tender-pwa image + image: alpine/git:2.40.1 + commands: + - APP_VERSION=pwa-$(git rev-list HEAD --count --no-merges) + - echo "Flutter PWA Version tags $APP_VERSION" + - echo -n "$APP_VERSION" > .tags + - name: tender pwa push to artifactory + image: plugins/docker + settings: + dockerfile: "Dockerfile" + username: "cicd" + password: + from_secret: "REGISTRY_PASSWORD" + repo: "artifactory.ravanertebat.ir/citizenclub/tm_app" + registry: "artifactory.ravanertebat.ir" + build_args: + - FLUTTER_VERSION=3.29.3 + - NGINX=1.25.2-alpine3.18-slim + +node: + tag: aecde-docker-runner + +trigger: + branch: + - dev + event: + - custom \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1dd5219 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,55 @@ +ARG FLUTTER_VERSION=3.29.3 +ARG NGINX=1.25.2-alpine3.18-slim + +# Stage 1 - Build Flutter Web on Debian +FROM debian:latest AS builder + +# Install system dependencies +RUN apt-get update && \ + apt-get install -y \ + git \ + curl \ + unzip \ + xz-utils \ + libglu1-mesa \ + cmake \ + clang \ + ninja-build \ + pkg-config \ + && rm -rf /var/lib/apt/lists/* + +# Install Flutter manually +RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter +WORKDIR /usr/local/flutter +RUN git checkout stable + +# Set Flutter environment +ENV PATH="$PATH:/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin" +RUN flutter doctor -v +RUN flutter config --enable-web + +# Copy app files +COPY . /app +WORKDIR /app + +# Clean and get packages +RUN flutter clean +RUN flutter pub get +RUN flutter build web --release --output=build/tender-pwa + +# Stage 2 - Runtime with NGINX +FROM nginx:${NGINX} + +# Install runtime dependencies +RUN apk --no-cache add \ + curl \ + tzdata \ + ca-certificates \ + && mkdir -p /var/log/app \ + && chown nginx:nginx /var/log/app + +# Copy build files from Debian builder +COPY --from=builder /app/build/tender-pwa /usr/tm/nginx/html + +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/configs/nginx.conf b/configs/nginx.conf new file mode 100644 index 0000000..9abc229 --- /dev/null +++ b/configs/nginx.conf @@ -0,0 +1,20 @@ +server { + listen 80; + server_name localhost; + + root /usr/tm/nginx/html; + + location / { + try_files $uri $uri/ /index.html; + add_header Cache-Control "no-cache, no-store, must-revalidate"; + } + + location /assets { + expires 1y; + access_log off; + add_header Cache-Control "public"; + } + + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; +} \ No newline at end of file