Giter VIP home page Giter VIP logo

flutter4cicd's Introduction

make run-time environment variables available to flutter code is not really working, in docker

so, a typical problem, we would like to have dynamic environments so that we can minimize docker images and versions of our executables etc

which also applies when we use OneCode -language (such as Flutter, Cordova etc.) This repo is based on Flutter in use with docker to support for Q&A regards article / port at stackoverflow

https://stackoverflow.com/questions/73837185/flutter-make-run-time-environment-variables-available-to-code-is-not-really-wor

Test it out...

Clone this repo, OR create you own Flutter starter app via Flutter Create and then copy/past from my lib/main.dart

git clone https://github.com/mklarsen/flutter4cicd.git

Now prep. flutter for build

flutter clean
flutter pub get
flutter config --build-dir=build
flutter config --enable-web

Build WebApp (no variables)

flutter build web -t lib/main.dart

Build docker with WebApp

docker build . -t flutter4devops

Now! Run the docker (with the variables as we like - It dosent work)

docker run \
  --env "BACKEND_APIURL=https://backendapi" \
  -p 80:80 flutter4devops

So this is a work-around, it will work sices we build the WebApp with the variables, so they are static in the Docker images.

Build WebApp (With variables)

flutter build web -t lib/main.dart --dart-define BACKEND_APIURL=http://backendapi.com

Build docker with WebApp

docker build . -t flutter4devops

Run the docker

docker run \
  -p 80:80 flutter4devops

Example from the result (Static build)

The WepAPP

From the container

Example from the result (run-time environment - not working)

From the container

From the container

You can also test it out localy via ex. Chrome

flutter run --dart-define BACKEND_APIURL=http://backendapi.com

flutter4cicd's People

Contributors

mklarsen avatar

Stargazers

 avatar

Watchers

 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.