如何解决Docker 和 Flutter Web 热重载
我正在尝试使用 docker compose 在 docker 中使用 Flutter 构建 Web 开发环境。 我坚持对 Flutter 进行热重载,有什么办法可以让它工作吗? (在 Flutter docker 机器上安装 VSCode 除外)
这是我的 Dockerfile
for Flutter 的样子:
#Stage 1 - Install dependencies and build the app
FROM debian:latest AS dev
workdir /root
# 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
workdir /root
copY . .
RUN Flutter build web
# Stage 2 - Create the run-time image
FROM Nginx
EXPOSE 3000
copY --from=dev /root/build /usr/share/Nginx/html
copY Nginx.conf /etc/Nginx/Nginx.conf
还有docker-compose
:
version: '3.8'
services:
# back-end api built with golang
golang:
build:
context: golang
target: dev
volumes:
- ./golang:/root
ports:
- "5000:5000"
env_file: .env
depends_on:
- db
# front-end built with react
Flutter:
build:
context: Flutter
target: dev
restart: always
volumes:
- ./Flutter:/root
ports:
- "3000:3000"
command: >
sh -c "Flutter pub get && Flutter run -d web-server --web-port 3000 --web-hostname 0.0.0.0"
# postgres is our primary data store
db:
build: db
volumes:
- ./db/migrations:/docker-entrypoint-initdb.d/migrations
# Nginx is used for ssl termination
Nginx:
build:
context: Nginx
target: dev
ports:
- "443:443"
depends_on:
- Flutter
- golang
仅供参考:项目设置基于 https://github.com/karlkeefer/pngr
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。