4

I'm trying to dockerize my flutter web project. And an image was created and the site run perfectly just the pictures of my website are not found and not displayed and I don't know why.it gave me this error :

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"]

this is server.sh file:

#!/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
16
  • 1
    thank you, do you have any idia about thie error please Commented May 13, 2022 at 9:52
  • I think your sever. Because server serves the static files Commented May 13, 2022 at 9:55
  • You need to give privileges to the static folder. So that your application and server will be able to communicate with each other. Commented May 13, 2022 at 9:59
  • how can I do that because I'm really new to docker Commented May 13, 2022 at 10:01
  • 1
    I'm using window 10 pro sir Commented May 13, 2022 at 10:26

1 Answer 1

1

So here is the thing. I think there are some problems with his code. As I tried to build with his code yesterday but things weren't working as they should be. I spend 2hours with his code of which 50% was spent on building the image but it was never completed. No problem I tried to modify some things and I am sharing some code with you on GitHub https://github.com/ash-0001/fludino.git. Just keep learning and sharing. Good Is Image.

The final image looks like this:

enter image description here

You have to use two commands to initialize this: Before that move into the directory with your cmd

  1. docker build -t flut .
  2. docker run -i -p 808:4040 -td flut
Sign up to request clarification or add additional context in comments.

2 Comments

I get this error ERROR [ 3/14] RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-d
Is that you are using Github codes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.