Flutter Web has developed into a stable version. The previously developed Qools project is now ready to be packaged and deployed to Docker.

Flutter web building

Before building, run the project to make sure it is running properly locally.

fvm flutter build web
Copy the code

CD project root directory, run the command above. This uses FVM to manage the FLUTTER SDK version.

The Web folder appears under the build file, and inside the folder are the web projects that you have built and need to deploy to the server.

Docker deployment

Docker is a software used to do software distribution, is a tool. Need to install docker on your own server, my Ali cloud server system: CentOS8. For reference:www.runoob.com/docker/cent…

Install the docker

Login server first, terminal input

sudo yum install -y docker
Copy the code

Start the Docker service

Sudo systemctl start docker systemctl enable dockerCopy the code

Get the nginx image

docker pull nginx
Copy the code

Run docker images to check whether the Nginx image is successfully obtained.

Continue to run the following command to run the Nginx server on port 80 of the host:

docker run -p 80:80 -d nginx
Copy the code

As shown in figure

List the container

docker ps
Copy the code

Remember the CONTAINER ID or NAMES, which will be used later.

Create a new directory on the server to store the previously built Web project and copy the project to your directory.

  • Server project path:/usr/qson/nginx/html

  • Configuration file path:/usr/qson/nginx/default.conf

If you do not need to change, you can omit this step

Copy the files in the two paths of the above server to the Docker container

  • Copy the default.conf file

If you don’t want to change default.conf, skip this step

docker cp /usr/qson/nginx/default.conf ${CONTAINER ID}://etc/nginx/conf.d/default.conf
Copy the code

${CONTAINER ID} Replace the previous CONTAINER ID with the CONTAINER ID f8e9BB900547, i.e

docker cp /usr/qson/nginx/default.conf f8e9bb900547://etc/nginx/conf.d/default.conf
Copy the code
  • Copying project files
docker cp /usr/qson/nginx/html f8e9bb900547://usr/share/nginx/html
Copy the code

Update the Docker Nginx via the server terminal

docker exec f8e9bb900547 nginx -s reload
Copy the code

Then the browser directly input IP address access, you can see their own project

Qools Web project address: http://101.37.147.31/

Docker container more commands

Run -d -p 80:80 --name mynginx nginx # run -d -d -p 80:80 --name mynginx nginx # run -d -d -p 80:80 --name mynginx nginx # Dokcer systemctl stop docker # stop docker # mynginx # nginx mynginx - LNP | grep process of 80 # to check 80 port kill 9 # docker ps - a closed process or docker 25158 ps # to check the container docker exec - it 9 df70f9a0714 / bin/bash # Docker logs -f mynginx # Track the log whereis nginx to query the nginx pathCopy the code

other

Docker ps -a docker ps -a docker ps -a docker Docker rm $(docker ps -a -q) // remove delete all dockers Images // View the image list docker rmI ImageId // Delete the image ImageId is the Id of the imageCopy the code