Skip to content

Instantly share code, notes, and snippets.

@srgtuszy
Created June 17, 2024 10:22
Show Gist options
  • Save srgtuszy/d19718adf78bf6076abd85d0fe003918 to your computer and use it in GitHub Desktop.
Save srgtuszy/d19718adf78bf6076abd85d0fe003918 to your computer and use it in GitHub Desktop.
Flutter for web Dockerfile. Use it if you want to deploy your flutter web app is a container
# Stage 1: Build
FROM debian:latest AS build-env
# Install flutter dependencies
RUN apt-get update
RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback python3 sed
RUN apt-get clean
# Clone the flutter repo
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
# Set flutter path
ENV PATH="${PATH}:/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin"
# Run flutter doctor
RUN flutter doctor -v
RUN flutter channel master
RUN flutter upgrade
# Copy files to container and build
RUN mkdir /app/
COPY . /app/
WORKDIR /app/
RUN flutter build web
# Stage 2: Copy artifacts into nginx
FROM nginx:1.21.1-alpine
COPY --from=build-env /app/build/web /usr/share/nginx/html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment