Skip to content

Instantly share code, notes, and snippets.

@chardskarth
Created January 3, 2024 02:34
Show Gist options
  • Save chardskarth/2f7f5eb0476001e84cc571d3511b7119 to your computer and use it in GitHub Desktop.
Save chardskarth/2f7f5eb0476001e84cc571d3511b7119 to your computer and use it in GitHub Desktop.
Dockerized flutter for development environment
version: '3.8'
services:
admin:
build: ./container/admin_webapp
volumes:
- "flutter_pub_cache:/home/developer/.pub-cache"
- "flutter_versions:/home/developer/fvm"
- "./admin-webapp:/home/developer/app"
volumes:
flutter_pub_cache:
flutter_versions:
FROM dart:3.2.4
RUN apt-get update --quiet --yes
RUN apt-get install --quiet --yes \
unzip \
apt-utils
ARG FVM_VERSION=2.4.1
RUN dart pub global activate fvm ${FVM_VERSION}
RUN apt install -y chromium
ENV CHROME_EXECUTABLE="/usr/bin/chromium"
RUN useradd -ms /bin/bash developer
RUN groupadd flutterdev
RUN usermod -aG flutterdev developer
RUN chown -R developer:flutterdev /root/.pub-cache
RUN chmod -R g+rwx /root/.pub-cache
RUN chmod -R 775 /root
ENV PATH "$PATH:/usr/bin/chromium:/home/developer/.pub-cache/bin:/root/.pub-cache/bin"
RUN mkdir /home/developer/fvm
ENV FVM_HOME /home/developer/fvm
RUN cp -r /root/.pub-cache /home/developer/.
ENV PUB_CACHE /home/developer/.pub-cache
RUN dart pub global activate fvm ${FVM_VERSION}
RUN mkdir /home/developer/app
WORKDIR /home/developer/app
RUN echo "#!/bin/sh\n" \
"chown -R developer:flutterdev /home/developer/.pub-cache\n" \
"chown -R developer:flutterdev /home/developer/fvm\n" \
"su developer\"$@\"\n" > /home/developer/entrypoint.sh
# "\n" > /home/developer/entrypoint.sh
RUN chmod +x /home/developer/entrypoint.sh
ENTRYPOINT /home/developer/entrypoint.sh
developer@7f648b92abdb:~/app$ fvm flutter run -d chrome --web-renderer html
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome... 31.8s
[CHROME]:Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
[CHROME]:[1223:1223:0102/202150.688842:FATAL:zygote_host_impl_linux.cc(200)] Check failed: . : Operation not permitted (1)
[CHROME]:[0102/202150.696332:ERROR:file_io_posix.cc(145)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[CHROME]:[0102/202150.696385:ERROR:file_io_posix.cc(145)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
[CHROME]:[1242:1242:0100/000000.712737:ERROR:zygote_linux.cc(662)] write: Broken pipe (32)
Failed to launch browser after 3 tries. Command used to launch it: /usr/bin/chromium --user-data-dir=/tmp/flutter_tools.XWWNGO/flutter_tools_chrome_device.VVJBWX --remote-debugging-port=34295 --disable-background-timer-throttling --disable-extensions --disable-popup-blocking --bwsi --no-first-run --no-default-browser-check --disable-default-apps --disable-translate http://localhost:45739
Failed to launch browser. Make sure you are using an up-to-date Chrome or Edge. Otherwise, consider using -d web-server instead and filing an issue at https://github.com/flutter/flutter/issues.
developer@7f648b92abdb:~/app$ fvm flutter build web
docker compose run -it --entrypoint /bin/sh admin "-c /bin/sh"
fvm flutter install
fvm flutter pub get
fvm flutter run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment