我正在try 将我的Flatter web项目归档.一张图片被创建出来,网站运行得很好,只是我的网站的图片没有找到,也没有显示出来,我不知道为什么.它给了我这个错误:

172.17.0.1 - - [12/May/2022 14:25:04] "GET / HTTP/1.1" 200 -

172.17.0.1 - - [12/May/2022 14:25:04] code 404, message File not found

172.17.0.1 - - [12/May/2022 14:25:04] "GET /packages/image_cropper_for_web/src/croppie/js/croppie.css HTTP/1.1" 404 -

172.17.0.1 - - [12/May/2022 14:25:05] code 404, message File not found

172.17.0.1 - - [12/May/2022 14:25:09] "GET /assets/photos/bgfinal.png HTTP/1.1" 404 -

172.17.0.1 - - [12/May/2022 14:25:09] code 404, message File not found

Dockerfile:

FROM ubuntu:20.04

RUN apt-get update
ARG DEBIAN_FRONTEND=noninteractive
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

# download Flutter SDK from Flutter Github repo
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter

# Set flutter environment path
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"

# Run flutter doctor
RUN flutter doctor

# 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 build web

# Record the exposed port
EXPOSE 5000

# make server startup script executable and start the web server
RUN ["chmod", "+x", "/app/server/server.sh"]

ENTRYPOINT [ "/app/server/server.sh"]

这是服务器.sh文件:

#!/bin/bash

# Set the port
PORT=5000

# Stop any program currently running on the set port
echo 'preparing port' $PORT '...'
fuser -k 5000/tcp

# switch directories
cd build/web/

# Start the server
echo 'Server starting on port' $PORT '...'
python3 -m http.server $PORT

推荐答案

事情就是这样.我觉得他的代码有问题.正如我昨天试图用他的代码构建的那样,但事情并没有按应有的方式运行.我花了2个小时研究他的代码,其中50%用于构建图像,但从未完成.没问题,我try 过修改一些东西,我正在GitHub https://github.com/ash-0001/fludino.git上与您共享一些代码.继续学习和分享.Good Is Image.

The final image looks like this:

enter image description here

必须使用两个命令来初始化:

  1. docker build-t flut.
  2. docker run-i-p 808:4040-td flut

Flutter相关问答推荐

Dart:如何定义嵌套泛型?

当我热重启时 productsController 没有启动,但是当我热重载它工作时,Flutter Getx

对目录中的每个项目运行“flutter clean”命令

Flutter ImagePicker 库不调用异步等待函数?

在 FutureProvider 中初始化 StateProvider

更新子时避免更新父变量

将字符串类型转换为另一种类型

如何在Flutter 中以编程方式删除图像背景?

Flutter Codemagic 静态页面失败,没有任何错误

如何使用提供程序从 Flutter 中的列表中删除项目?

NoSuchMethodError(NoSuchMethodError:在 null 上调用了方法“[]”.接收方:null try 调用:[](0))

在 Dart 中将 Map 元素添加到 List 中

如何在Flutter 中创建类似信用卡号的TextField?

ListView Builder 与 SingleChildScrollView + Row 组合

容器在动画期间丢失盒子阴影

添加 listview builder 时,整个屏幕变为空白

(dart / flutter) 使用“mongo_dart”进行用户认证

您的项目需要更新版本的 Kotlin Gradle 插件.

无法获取“play-services-location/maven-metadata.xml”.从服务器收到状态码 502:Bad Gateway

使用 Geolocation 插件编译时出错