Create Flutter Environment with Docker Compose to Generate Web/Android/Linux Builds

Tiempo de lectura: < 1 minuto

Reading time: < 1 minute

Hello everyone, today we are going to see how we can create a Flutter environment using Docker containers that will allow us to generate a build of our project.

This environment will allow us to both develop and generate an APK or web with our Flutter project.

The first thing we are going to do is create the Docker Compose image:

  flutter_dev:
    image: mobiledevops/flutter-sdk-image:3.7.12
    restart: unless-stopped
    container_name: flutter_dev
    volumes:
      - ./app_flutter:/home/mobiledevops/app
    networks:
      - docker-network
    command: tail -f /dev/null

We use the image from https://hub.docker.com/r/mobiledevops/flutter-sdk-image to create our Flutter container.

We have created a volume in our external folder app_flutter that communicates with the internal folder APP.

To make the container work in the background, we add: command: tail -f /dev/null

In app_flutter, we will copy our Flutter project.

To execute the build, you will need to run:

docker exec flutter_dev flutter build web

Remember that the build is generated inside /build/web, and to run it, you should use either Apache2 or Nginx.

If we want to use flutter doctor, we will run:

docker exec flutter_dev flutter doctor

Leave a Comment