Code Monkey home page Code Monkey logo

heroku-buildpack-flutter's Introduction

Heroku Buildpack for Flutter

header Automate your deployments on Heroku easily.

๐Ÿ”จ Setup

Add this Buildpack in your Heroku app

In dashboard:

You can copy the link of this repository and paste it in buildpacks or write diezep/flutter and will be added automatically.

In Heroku CLI:

$ heroku buildpacks:set diezep/flutter -a <Heroku App name>

Optional

You can add optional environment variables to customize the deployment of your project but nothing is required, all are optional.

๐Ÿšง Environment variables:

All variables were built following the structure FLUTTER_VARNAME to identified easily in Heroku configurations. If you want to use some variable, remember use the structure following to the variable.

Variable Type Default Description
CLEANUP boolean true Remove uneccessary files of your project after the compile.
VERSION string Last version in stable channel. The name of the version you want to use to compile the project.
BUILD string flutter build web --release --quiet Customize the command to compile the project.

Set variable

Example of setting CLEANUP var in Heroku CLI:

$ heroku config:set FLUTTER_CLEANUP=true -a project-name

Example

The next image is an example of setting environment variables following the structure mentioned above :

example_use_in_variables

๐Ÿ“ Final note

This buildpack is unofficial that means i don't have any conection with Heroku or Google from Flutter developer team . This repository was made as a hobby, i'm always interested in learn new things, this is one demostration of that :)

Recently, @ludwiktrammer developed a lighter version of this buildpack with some improvements, if you are having problems with size of project or you are using Heroku CI, i invite you to test it. here's the repo

heroku-buildpack-flutter's People

Contributors

diezep avatar huzaifah0x00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

heroku-buildpack-flutter's Issues

Heroku Buildpack Flutter's fork: Heroku Buildpack Flutter Light

Not really an issue, just wanted to let you know that we created a Heroku Buildpack for building Flutter Web projects, that is based on Heroku Buildpack Flutter's: Heroku Buildpack Flutter Light.

Initially the idea was to send our changes back to this repo in a Pull Request, but we realized that we needed to make different architectural tradeoffs in a way that's backwards incompatible, which would make it impossible to you to merge the Pull Request (among other things, we removed the server completely). That's why we published this under a different name instead.

How to switch to stable release?

I keep getting this error when on Flutter 2.10.0-0.2.pre โ€ข channel beta and i can't figure out how to switch to the stable version.

I've set the environment variable to the latest stable version and it keeps going back to 2.10.0-0.2.pre.

remote: Target dart2js failed: Exception: /app/.pub-cache/hosted/pub.dartlang.org/platform-3.0.2/lib/src/interface/local_platform.dart:46:19: remote: Error: Member not found: 'packageRoot'. remote: io.Platform.packageRoot; // ignore: deprecated_member_use remote: ^^^^^^^^^^^ remote: Error: Compilation failed.

Any help would be really appreciated.

@diezep

Redirect to index.html

I use a named routing in my project. If I navigate to the Stacks page, the URL becomes localhost:123/stacks and so on. When I refresh the page locally, the Stacks page opened up. But after deploying to Heroku, after refreshing on stacks page, I get only "Not Found" text.

I think Heroku should redirect all routes to the index.html file.

I found a solution for the Firebase, but can't find one for Heroku:
https://stackoverflow.com/a/51236284/1419756

Thank you!

[remote rejected] master -> main (pre-receive hook declined)

Hi,
I am working on a flutter project that i want to deploy on heroku using your buildpack. I followed other steps, after running heroku buildpacks:set diezep/flutter -a and get the meesage
Buildpack set. Next release on herokuappname will use diezep/flutter.
Run git push heroku main to create a new release using this buildpack.
I run this command git push heroku master:main
Results
Enumerating objects: 97, done.
Counting objects: 100% (97/97), done.
Delta compression using up to 8 threads
Compressing objects: 100% (79/79), done.
Writing objects: 100% (97/97), 56.05 KiB | 2.24 MiB/s, done.
Total 97 (delta 7), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> https://buildpack-registry.s3.amazonaws.com/buildpacks/diezep/flutter.tgz app detected
remote: -----> Installing SDK from Github repository.
remote: -----> Running flutter upgrade command
remote: Downloading Dart SDK from Flutter engine 609036f2bf7cae17a0b88c21fb3bdaff7159b713...
remote: % Total % Received % Xferd Average Speed Time Time Time Current
remote: Dload Upload Total Spent Left Speed
remote: 100 190M 100 190M 0 0 92.6M 0 0:00:02 0:00:02 --:--:-- 92.6M
remote: Building flutter tool...
remote:
remote: โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
remote: โ•‘ Welcome to Flutter! - https://flutter.dev โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ The Flutter tool uses Google Analytics to anonymously report feature usage โ•‘
remote: โ•‘ statistics and basic crash reports. This data is used to help improve โ•‘
remote: โ•‘ Flutter tools over time. โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ Flutter tool analytics are not sent on the very first run. To disable โ•‘
remote: โ•‘ reporting, type 'flutter config --no-analytics'. To display the current โ•‘
remote: โ•‘ setting, type 'flutter config'. If you opt out of analytics, an opt-out โ•‘
remote: โ•‘ event will be sent, and then no further information will be sent by the โ•‘
remote: โ•‘ Flutter tool. โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ By downloading the Flutter SDK, you agree to the Google Terms of Service. โ•‘
remote: โ•‘ Note: The Google Privacy Policy describes how data is handled in this โ•‘
remote: โ•‘ service. โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ Moreover, Flutter includes the Dart SDK, which may send usage metrics and โ•‘
remote: โ•‘ crash reports to Google. โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ Read about data we send with crash reports: โ•‘
remote: โ•‘ https://flutter.dev/docs/reference/crash-reporting โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ See Google's privacy policy: โ•‘
remote: โ•‘ https://policies.google.com/privacy โ•‘
remote: โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
remote:
remote: Downloading Material fonts... 502ms
remote: Downloading Gradle Wrapper... 12ms
remote: Downloading package sky_engine... 139ms
remote: Downloading flutter_patched_sdk tools... 1,076ms
remote: Downloading flutter_patched_sdk_product tools... 914ms
remote: Downloading linux-x64 tools... 2,081ms
remote: Downloading linux-x64/font-subset tools... 416ms
remote: Switching to flutter channel 'beta'...
remote: git: Switched to a new branch 'beta'
remote: git: Branch 'beta' set up to track remote branch 'beta' from 'origin'.
remote: Successfully switched to flutter channel 'beta'.
remote: To ensure that you're on the latest build from this channel, run 'flutter upgrade'
remote: Downloading Dart SDK from Flutter engine 7a8f8ca02c276dce02f8dd42a44e776ac03fa9bc...
remote: % Total % Received % Xferd Average Speed Time Time Time Current
remote: Dload Upload Total Spent Left Speed
remote: 100 173M 100 173M 0 0 98.5M 0 0:00:01 0:00:01 --:--:-- 98.4M
remote: Building flutter tool...
remote:
remote: โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
remote: โ•‘ Welcome to Flutter! - https://flutter.dev โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ The Flutter tool uses Google Analytics to anonymously report feature usage โ•‘
remote: โ•‘ statistics and basic crash reports. This data is used to help improve โ•‘
remote: โ•‘ Flutter tools over time. โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ Flutter tool analytics are not sent on the very first run. To disable โ•‘
remote: โ•‘ reporting, type 'flutter config --no-analytics'. To display the current โ•‘
remote: โ•‘ setting, type 'flutter config'. If you opt out of analytics, an opt-out โ•‘
remote: โ•‘ event will be sent, and then no further information will be sent by the โ•‘
remote: โ•‘ Flutter tool. โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ By downloading the Flutter SDK, you agree to the Google Terms of Service. โ•‘
remote: โ•‘ Note: The Google Privacy Policy describes how data is handled in this โ•‘
remote: โ•‘ service. โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ Moreover, Flutter includes the Dart SDK, which may send usage metrics and โ•‘
remote: โ•‘ crash reports to Google. โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ Read about data we send with crash reports: โ•‘
remote: โ•‘ https://flutter.dev/docs/reference/crash-reporting โ•‘
remote: โ•‘ โ•‘
remote: โ•‘ See Google's privacy policy: โ•‘
remote: โ•‘ https://policies.google.com/privacy โ•‘
remote: โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
remote:
remote: Flutter is already up to date on channel beta
remote: Flutter 1.25.0-8.3.pre โ€ข channel beta โ€ข https://github.com/flutter/flutter.git
remote: Framework โ€ข revision 5d36f2e7f5 (3 days ago) โ€ข 2021-01-14 15:57:49 -0800
remote: Engine โ€ข revision 7a8f8ca02c
remote: Tools โ€ข Dart 2.12.0 (build 2.12.0-133.7.beta)
remote: -----> Enabling Web support
remote: Setting "enable-web" value to "true".
remote:
remote: You may need to restart any open editors for them to read new settings.
remote: -----> Running flutter clean command.
remote: Downloading package sky_engine... 501ms
remote: Downloading flutter_patched_sdk tools... 1,077ms
remote: Downloading flutter_patched_sdk_product tools... 932ms
remote: Downloading linux-x64 tools... 2,045ms
remote: Downloading linux-x64/font-subset tools... 293ms
remote: -----> Getting packages from Flutter project
remote: Running "flutter pub get" in build_b95615a5... 2,020ms
remote: -----> Compiling the project.
remote: Downloading Web SDK... 3.3s
remote: Missing index.html.
remote: -----> Saving Flutter SDK in Cache
remote: mv: cannot stat 'TO_DELETE/build/web/*': No such file or directory
remote: ! Push rejected, failed to compile https://buildpack-registry.s3.amazonaws.com/buildpacks/diezep/flutter.tgz app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 75d32182cfb0a7726f81e693171f09d0190a4679
remote: !
remote: ! We have detected that you have triggered a build from source code with version 75d32182cfb0a7726f81e693171f09d0190a4679
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku :main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to herokuappname.
remote:
To https://git.heroku.com/houseofdani.git
! [remote rejected] master -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/herokuappnamegit'

May you assist

json_serializable build error

Hi there, I'm trying this build-pack but I have a build error about json_serializable library. It needs to run flutter pub run build_runner build. How can i achieve that? Maybe my app configuration is wrong, i'm also new at flutter.

part 'subscription.g.dart';

     ^

lib/models/subscription.dart:3:6:

Error: Can't use 'lib/models/subscription.g.dart' as a part, because it has no 'part of' declaration.

part 'subscription.g.dart';

     ^

lib/models/subscription.dart:13:7:

Error: Method not found: '_$SubscriptionFromJson'.

      _$SubscriptionFromJson(json);

      ^^^^^^^^^^^^^^^^^^^^^^

lib/models/subscription.dart:15:36:

Error: The method '_$SubscriptionToJson' isn't defined for the class 'Subscription'.

 - 'Subscription' is from 'package:trade_bot/models/subscription.dart' ('lib/models/subscription.dart').

  Map<String, dynamic> toJson() => _$SubscriptionToJson(this);

                                   ^^^^^^^^^^^^^^^^^^^^

Error: Compilation failed.

FLUTTER_VERSION variable do not work, throws error every time

I found that this pack always try to build the app with the latest flutter version available, tho the docs says that if you set the variable FLUTTER_VERSION it should install it, but it throws an error, out example:

-----> Restoring Flutter SDK from CACHE
Building flutter tool...
-----> Installing Flutter SDK version : 3.13.2
Could not find a command named "version".
Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.

Related to:

Idea

The way to install new version of flutter is not using flutter version because that command do not exist, it is bad here:
https://github.com/diezep/heroku-buildpack-flutter/blob/eecebf9581129aa31f587cdf41ec2a3cbf0fdbe4/bin/compile#L48C11-L48C26

No active package dhttpd

Compiling the app seems fine:
Screenshot 2023-05-06 at 3 04 27 AM

However in the logs:

2023-05-05T22:56:38.000000+00:00 app[api]: Build succeeded
2023-05-05T22:57:54.483665+00:00 heroku[web.1]: Starting process with command `/app/dart-sdk/bin/dart pub global run dhttpd --host 0.0.0.0 --path /app/`
2023-05-05T22:57:55.455193+00:00 app[web.1]: No active package dhttpd.
2023-05-05T22:57:55.630830+00:00 heroku[web.1]: Process exited with status 65
2023-05-05T22:57:55.672732+00:00 heroku[web.1]: State changed from starting to crashed

Am I missing something?

SUBDIR env var

Hello there, I would really appreciate if you'd implement the SUBDIR environment variable soon, because otherwise I can't use this buildpack (and I have to if I want to test with heroku). It would really help alot :)

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.