Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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
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
  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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
docker exec flutter_dev flutter build web
docker exec flutter_dev flutter build web
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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
docker exec flutter_dev flutter doctor
docker exec flutter_dev flutter doctor
docker exec flutter_dev flutter doctor

0

Leave a Comment