2024-10-12
环境配置
0

目录

Compiling QGIS with docker
1 Overview
2 Installing
3 Docker Image
4 Docker Container
5\. Start to Compile QGIS

QGIS是一个开源的GIS软件,对于遥感测算,地图绘制,可视化地理数据有重要作用。并且经常面临二次开发的需求,下面将详细描述如何使用docker在linux上编译windows版本的应用程序。 注:本文写于大二时期,只有英文版本,并且当时英文写作水平有限😩

Compiling QGIS with docker

1 Overview

This essay contains following four sections:

  • installing docker on Linux Os
  • using docker images
  • using docker containers
  • compiling QGIS inside docker container

If you had installed docker on your computer and comprehended the concept of docker container and docker image. We recommend you read the fourth section directly.

2 Installing

Base centos:

$ sudo yum install docker-ce

Base ubuntu:

$ sudo apt-get install docker-ce docker-ce-cli containerd.io`

3 Docker Image

This section introduces methods of applying docker images and related terms. On the prompt command type:

$ docker images
REPOSITORYTAGIMAGE IDCREATEDSIZE
ubuntulatestxxx7days agoxxMB

Then you will get the above, this command listed all localimages, where "REPOSITORY" is resource of the image and "IMAGE ID" is an unique ID for every image that docker engine generate randomly.

"TAG" is a representation of different edition image. "SIZE" represents the size of image. The more commands you run in the container, the bigger the image that from container commit(especially apt upgrade!) .

When we want to utilize image provided by other people:

$ docker pull {repository:tag}

If you want to remove one of your images:

$ docker rm ubuntu

4 Docker Container

The container is just like sandboxes that can run applications inside, which is dynamic and able to convert into images. To search all running containers, type the following:

bash
$ docker ps

Then will get the following:

CONTAINER IDIMAGECOMMANDCREATEDSTATUSPORTSNAMES
xxxubuntu"bin/bash"7 days agoEXIT(0)xx
generate randomly

To list all containers, including running and suspended containers, use:

bash
$ docker ps -a

To start a container:

bash
$ docker run -i -t {image_id} /bin/bash
  • -i: Standard input and output.
  • -t: Terminal.
  • /bin/bash: Automatically executes the command inside the container.

Alternatively, you can use:

bash
$ docker exec -it {container_name} /bin/bash

This keeps the container in the "UP" status, even if you use the exit command inside.

5. Start to Compile QGIS

This section describes how to build the QGIS project using Docker. Assuming you have Docker installed:

  1. Pull the image with Mingw dependencies from the official repository:

    bash
    $ docker pull ghcr.io/qgis/qgis/qgis3-mingw-buildenv-stages:1
  2. Run a container on this image and keep it running:

    bash
    $ docker run -it ghcr.io/qgis/qgis/qgis3-mingw-buildenv-stages:1 /bin/bash
  3. To exit the container:

    bash
    $ exit
  4. Restart the container:

    bash
    $ docker restart {container_name}

    Replace {} with the container name or ID.

  5. Copy QGIS project files into the running container:

    bash
    $ docker cp ./QGIS {container_name}:/workspace
  6. Enter the container and change the directory:

    bash
    $ docker exec -it {container_id} /bin/bash # cd /workspace/QGIS/ms-windows/mingw
  7. Run the build shell scripts:

    bash
    # ./build.sh
  8. After a while, a /dist folder will be generated. Compress and copy it to the host system:

    bash
    # tar -cvfz dist.tar.gz ./dist # exit
  9. Finally, download the compressed file to the Windows system using the "sftp" protocol.

本文作者:James

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!