Giter Club home page Giter Club logo

flutter-docker-deps's Introduction

flutter-docker-deps

A docker image with the dependancies required to install and run Flutter tests. This can be used to run tests in a consistent environment without needing to worry about system differences, updates, etc.

This project is inspired by appleboy/flutter-docker. The main difference being that the Flutter version is dynamic and set by the project instead of having to have a Docker image for each Flutter version. The version will be installed if missing from the install cache.

This also allows the same Docker image to work for mutiple Flutter projects, all using different versions of Flutter.

How to use

See the example folder of this repo. This example Flutter project folder was created using flutter create with 2 scripts added.

Add scripts similar to the ones in the example, then just run ./docker-run-tests.sh.

docker-run-tests.sh

PROJECT_PATH=$PWD

docker run -ti \
    -v ${PROJECT_PATH}:/project \
    -v $FLUTTER_INSTALL_CACHE_PATH:/flutter-installs \
    jasonrai/flutter-docker-deps:latest \
    /bin/sh -c "./project/docker-flutter-install-then-test.sh"

This script runs the docker image, mounting 2 directories from the host OS onto the container.

PROJECT_PATH is the path to your flutter project. If you keep this script in the root of your Flutter project, you can keep PROJECT_PATH=$PWD to set the path for you.

$FLUTTER_INSTALL_CACHE_PATH is a bash environment variable. You need to set it to where you want to cache Flutter installs on the host machine.

You may need to remove the i option from from the command if you are running in a non-interactive console This will be required on Jenkins for example.

docker-flutter-install-then-test.sh

VERSION="1.5.4-hotfix.2"
CHANNEL="stable"

cd /flutter-installs

if [ ! -d "v${VERSION}-${CHANNEL}" ]; then
    wget https://storage.googleapis.com/flutter_infra/releases/${CHANNEL}/linux/flutter_linux_v${VERSION}-${CHANNEL}.tar.xz
    mkdir v${VERSION}-${CHANNEL}
    tar xf flutter_linux_v${VERSION}-${CHANNEL}.tar.xz -C v${VERSION}-${CHANNEL}
fi

cd ..
export PATH=/flutter-installs/v${VERSION}-${CHANNEL}/flutter/bin:$PATH
cd project/
flutter packages get
flutter test

This script installs Flutter if needed then runs flutter test. Beware that this script is ran inside the container, it's not the bash environment of the host machine like the previous script is.

In this script set the version and release channel of Flutter that you want to test on. It will only download missing versions of Flutter. So the first time you run tests for each Flutter version expect them to take longer.

flutter-docker-deps's People

Contributors

misterjimson avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.