AngularDart: How to run locally release build - angular-dart

I made release build of AngularDart app with webdev build.
How can I run it locally before deploying to remote hosting server?
At the moment I am using Built-in web server in PHP:
cd build
php -S localhost:8888
Is it possible to run locally release build with webdev or build_runner commands?
Thank you in advance!

Sure!
webdev serve --release
or, if you want to run it with a specific build config, replace the build with serve in your build_runner command:
pub run build_runner serve -c production --release -o web:build
And if you want to get to it from somewhere other then localhost:
webdev serve --release --hostname 0.0.0.0

Related

Flutter web | failed to create Docker file

Below issue facing while creating docker file in flutter web
enter image description here
anyone have idea about how to create docker file in flutter web.....
I tried many resources but still stuck in issue...
resource or link or solution about same
It is hard to help you without seeing your Dockerfile.
This is the multistaged one I use with nginx:
#Stage 1 - Install dependencies and build the app
FROM debian:latest AS build-env
# Install flutter dependencies
RUN apt-get update
RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback lib32stdc++6 python3
RUN apt-get clean
# Clone the flutter repo
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
# Set flutter path
# RUN /usr/local/flutter/bin/flutter doctor -v
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"
# Run flutter doctor
RUN flutter doctor -v
# Enable flutter web
RUN flutter channel master
RUN flutter upgrade
RUN flutter config --enable-web
# Copy files to container and build
RUN mkdir /app/
COPY . /app/
WORKDIR /app/
RUN flutter create .
RUN flutter build web
# Stage 2 - Create the run-time image
FROM nginx:1.21.1-alpine
COPY --from=build-env /app/build/web /usr/share/nginx/html
If you need a highly optimized image I would not use this one. How ever it does the trick for me.

How debug a Flutter test running inside a Docker container

I am following the Reduce your CI cost using Docker to run local tests article and managed to run my tests inside a Ubuntu docker container. However, I have one test which fails after about 10 minutes of running. Here is the error I see:
# flutter test test/lib/mobile/services/sync/sync_service_test.dart
12:25 +0 -1: apiSync It should throw an exception if the sync fails [E]
TimeoutException after 0:10:00.000000: Test timed out after 10 minutes.
dart:isolate _RawReceivePortImpl._handleMessage
However, this test runs fine in macOS (my machine and in Bitrise CI).
To help resolve this issue, I am trying to find a way to debug this test. Is there a way I can remotely debug a test running inside this Docker container?
This is a copy of my modified Dockerfile:
# Need to match the version of Linux your CI is running on
FROM ubuntu:20.04
# Prerequisites
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris
RUN apt update && apt install -y curl git unzip xz-utils zip libglu1-mesa openjdk-8-jdk wget libsqlite3-dev
WORKDIR /home/developer
# Download Flutter SDK
ARG flutter_version
RUN git clone https://github.com/flutter/flutter.git -b ${flutter_version}
ENV PATH "$PATH:/home/developer/flutter/bin"
COPY pubspec.* /home/developer/project/
WORKDIR /home/developer/project
RUN flutter pub get
COPY *.yaml *.json /home/developer/project/
COPY android /home/developer/project/android
COPY assets /home/developer/project/assets
COPY doc /home/developer/project/doc
COPY docker /home/developer/project/docker
COPY ios /home/developer/project/ios
COPY lib /home/developer/project/lib
COPY macos /home/developer/project/macos
COPY scripts /home/developer/project/scripts
COPY test /home/developer/project/test
COPY test_environment /home/developer/project/test_environment
COPY tool /home/developer/project/tool
COPY web /home/developer/project/web
# Run basic check to download Dark SDK
RUN flutter doctor
I would like to know the possibility of remote debugging rather than trying to solve the issue for this particular test.
Thanks in advance 🙏 !!!

Difference between flutter run and flutter run -d

AFAIK, when you run the following command, it runs the app in the debug mode.
flutter run
But the following command also does the same thing. So, is there any difference between the two commands?
flutter run -d
-d lets you specify a run target, e.g. flutter run -d web or flutter run -d linux
$ flutter run linux
Target file "linux" not found.
$ flutter run -d linux
Launching lib/main.dart on Linux in debug mode...
Building Linux application...
$ flutter run --help
Run your Flutter app on an attached device.
Global options:
-d, --device-id Target device id or name (prefixes allowed).
Command (linux part without -d) is a --target flag by default:
-t, --target=<path> The main entry-point file of the application, as run on the device.
If the --target option is omitted, but a file name is provided on the command line, then that is used instead.
(defaults to "lib/main.dart")

VSTS Build is failing with Polymer build

I am running npm,lerna,yarn and bootstrap in my VSTS build definitions via Command line task after running all the above commands I am running npm run build command but while running npm run build command its failing with 'polymer' is not recognized as an internal or external command.Please help me on this.I tried running polymer in a command line passing polymer as a tool and arguments as build even though its failing.Please help me.
Make sure that the polymer-cli npm package is listed in your dev dependencies (at least it sounds like a dev dependency to me) in your package.json. Also make sure you run npm install before you run npm run build. You might have to point your NPM build script to the Polymer package in your node_modules folder because it is not installed globale on the build server

code ship fails with error - You have to be inside an angular-cli project in order to use the serve command

For my angular CLI/Bitbucket project I am running following script in Codeship but it gives error You have to be inside an angular-cli project in order to use the serve command.
#install node version, 4.x is required for the angular-cli
nvm install 4.1
#install angular-cli
npm install angular-cli
#run npm install for your project dependencies
npm install
Under that script is the "Test Pipelines", where the script is setup to run the tests.
#serve the application adding '&' to run command in background
ng serve &
#start end to end tests using protractor
ng test
#if all of the tests pass, then build the production assets
ng build -prod
According to https://github.com/angular/angular-cli/issues/4379 this error message is usually triggered if you're using the (now deprecated) angular-cli package.
Either update the package.json file for the project to reference the #angular/cli package, or make sure to install this package instead of the deprecated one.