ci/cd: add Dockerfile and nginx.conf for production deployment
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
# --- ETAPA 1: Compilación ---
|
||||
# Usamos el registro moderno de CirrusLabs (ghcr.io) con tu versión de Flutter
|
||||
FROM ghcr.io/cirruslabs/flutter:3.41.0 AS build-stage
|
||||
|
||||
# Variables de entorno para Flutter/Pub en Docker (incluye mirror oficial para evitar bloqueos de IP en datacenters)
|
||||
ENV PUB_ENVIRONMENT=docker
|
||||
ENV PUB_CACHE=/root/.pub-cache
|
||||
ENV PUB_HOSTED_URL=https://pub.flutter-io.cn
|
||||
ENV FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
|
||||
|
||||
# Tus variables de Coolify
|
||||
ARG COOLIFY_URL=https://med.hidalyx.com
|
||||
ARG COOLIFY_FQDN=med.hidalyx.com
|
||||
|
||||
# Directorio de trabajo dentro del contenedor
|
||||
WORKDIR /app
|
||||
|
||||
# Desactivamos telemetría
|
||||
RUN flutter config --no-analytics
|
||||
|
||||
# Paso 1: Copiamos descriptor y lockfile oficial
|
||||
COPY pubspec.yaml pubspec.lock ./
|
||||
|
||||
# Descargamos dependencias de Flutter
|
||||
RUN flutter pub get
|
||||
|
||||
# Copiamos todo tu código fuente al contenedor
|
||||
COPY . .
|
||||
|
||||
# Compilamos para web en modo release explícito
|
||||
RUN flutter build web --release --no-web-resources-cdn
|
||||
|
||||
# --- ETAPA 2: Producción con Nginx ---
|
||||
FROM nginx:alpine
|
||||
|
||||
# Copiamos la carpeta build/web ya generada en la etapa anterior
|
||||
COPY --from=build-stage /app/build/web /usr/share/nginx/html
|
||||
|
||||
# Copiamos tu configuración personalizada de Nginx
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# Arrancamos el servidor
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Reference in New Issue
Block a user