I'm trying to web development environment with Flutter in docker with docker compose. I stuck with a hot reload for Flutter, is there any way to make it work? (except installing VSCode on flutter docker machine)
Here is how my Dockerfile for flutter looks like:
#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
And 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
FYI: Project setup is based on the https://github.com/karlkeefer/pngr
Aucun commentaire:
Enregistrer un commentaire