├── Dockerfile ├── LICENSE ├── README.rst ├── build_qt.sh ├── docker-build.sh ├── docker-run-qtcreator.sh ├── docker-run-shell.sh ├── docker-start-qtcreator.sh └── docker-start-shell.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | 3 | ENV QT_VERSION v5.9.1 4 | ENV QT_CREATOR_VERSION v4.3.1 5 | 6 | # Build prerequisites 7 | RUN apt-get -y update && apt-get -y install qtbase5-dev \ 8 | libxcb-xinerama0-dev \ 9 | build-essential \ 10 | python 11 | 12 | # Other useful tools 13 | RUN apt-get -y update && apt-get -y install tmux \ 14 | wget \ 15 | zip \ 16 | git \ 17 | vim 18 | 19 | # Simple root password in case we want to customize the container 20 | RUN echo "root:root" | chpasswd 21 | 22 | RUN useradd -G video -ms /bin/bash user 23 | 24 | RUN mkdir -p /qt/build 25 | 26 | WORKDIR /qt/build 27 | 28 | ADD build_qt.sh /qt/build/build_qt.sh 29 | RUN QT_VERSION=$QT_VERSION QT_CREATOR_VERSION=$QT_CREATOR_VERSION /qt/build/build_qt.sh 30 | 31 | USER user 32 | 33 | WORKDIR /qt 34 | 35 | CMD ["bash"] 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2018 Erik Stromdahl 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | QT docker development environment 2 | ================================= 3 | 4 | Overview 5 | ++++++++ 6 | 7 | This docker image is intended to provide a development environment for Qt. 8 | It contains *qtcreator* as well as the Qt libraries and tools (such as 9 | qmake etc.) 10 | 11 | The Qt libraries and *qtcreator* are built from source with the script 12 | *build_qt.sh*. The source is obtained from the official Qt git repositories. 13 | 14 | Installation 15 | ++++++++++++ 16 | 17 | See the official docker documentation for a general overview of docker 18 | and how to install: 19 | 20 | https://docs.docker.com/engine/installation/linux/ 21 | 22 | Build and launch docker image 23 | +++++++++++++++++++++++++++++ 24 | 25 | Build the docker image 26 | ---------------------- 27 | 28 | .. code-block:: bash 29 | 30 | git clone https://github.com/erstrom/docker-qt.git 31 | cd docker-qt 32 | ./docker-build.sh 33 | 34 | During the build process, *build_qt.sh* will clone the Qt git repos and 35 | build the versions specified by **QT_VERSION** and **QT_CREATOR_VERSION**. 36 | If you want other versions than the default, just update *Dockerfile* with 37 | the desired versions (must be valid git tags in the repo's). 38 | 39 | Create a container 40 | ------------------ 41 | 42 | Use ``docker run`` to create a container. Two wrapper scripts are included 43 | that can be used to ease the creation of containers: 44 | 45 | - *docker_run_shell.sh* 46 | - *docker_run_qtcreator.sh* 47 | 48 | *docker_run_shell.sh* creates a container and sets docker *COMMAND* to the 49 | default bash shell. This is useful if the container is going to be customized. 50 | 51 | *docker_run_qtcreator.sh* sets docker *COMMAND* to *qtcreator*. This will 52 | launch *qtcreator* as soon as the container is started. 53 | 54 | The wrapper scripts invokes ``docker run`` with a few options that makes 55 | it possible for GUI applications inside the container (like *qtcreator*) 56 | to connect to the xorg server on the host. 57 | 58 | Start an existing container 59 | --------------------------- 60 | 61 | ``docker run`` should only be run once, so if you want to restart an already 62 | created container you should use ``docker start``. 63 | 64 | The below two wrapper scripts exist for ``docker start``: 65 | 66 | - *docker_start_shell.sh* 67 | - *docker_start_qtcreator.sh* 68 | 69 | The scripts will (re)start the containers created by the *docker_run_...* scripts, 70 | i.e., *docker_start_qtcreator.sh* will start the container created by 71 | *docker_run_qtcreator.sh*. 72 | 73 | -------------------------------------------------------------------------------- /build_qt.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # This script is licensed under the MIT license: 4 | # 5 | # MIT License 6 | # 7 | # Copyright (c) 2017-2018 Erik Stromdahl 8 | # 9 | # Permission is hereby granted, free of charge, to any person obtaining a copy 10 | # of this software and associated documentation files (the "Software"), to deal 11 | # in the Software without restriction, including without limitation the rights 12 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | # copies of the Software, and to permit persons to whom the Software is 14 | # furnished to do so, subject to the following conditions: 15 | # 16 | # The above copyright notice and this permission notice shall be included in all 17 | # copies or substantial portions of the Software. 18 | # 19 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | # SOFTWARE. 26 | # 27 | # ----------------------------------------------------------------------------- 28 | # 29 | # Script used to build QT creator from source. 30 | # The QT libraries and tools are needed by QT creator and are also built 31 | # 32 | # The content of this script has been derived from the below two pages: 33 | # 34 | # http://wiki.qt.io/Building_Qt_5_from_Git 35 | # http://wiki.qt.io/Building_Qt_Creator_from_Git 36 | 37 | SCRIPT_PATH=`readlink -f $0` 38 | SCRIPT_DIR=`dirname $SCRIPT_PATH` 39 | 40 | # Configuration env vars will be set to default values if not defined. 41 | [[ -z ${QT_TOP_DIR+x} ]] && QT_TOP_DIR=$SCRIPT_DIR 42 | [[ -z ${QT_VERSION+x} ]] && QT_VERSION="master" 43 | [[ -z ${QT_J_LEVEL+x} ]] && QT_J_LEVEL=$((`nproc`+1)) 44 | [[ -z ${QT_GIT_URL+x} ]] && QT_GIT_URL="https://code.qt.io/qt/qt5.git" 45 | [[ -z ${QT_WORKING_DIR+x} ]] && QT_WORKING_DIR="qt5" 46 | [[ -z ${QT_INIT_REPOSITORY_OPTS+x} ]] && QT_INIT_REPOSITORY_OPTS="--module-subset=default,-qtwebkit,-qtwebkit-examples,-qtwebengine" 47 | [[ -z ${QT_CONFIGURE_OPTS+x} ]] && QT_CONFIGURE_OPTS="-opensource -nomake examples -nomake tests -confirm-license" 48 | [[ -z ${QT_CREATOR_GIT_URL+x} ]] && QT_CREATOR_GIT_URL="https://code.qt.io/qt-creator/qt-creator.git" 49 | [[ -z ${QT_CREATOR_VERSION+x} ]] && QT_CREATOR_VERSION="master" 50 | [[ -z ${QT_CREATOR_WORKING_DIR+x} ]] && QT_CREATOR_WORKING_DIR="qt-creator" 51 | 52 | # Enter the top build dir 53 | pushd $QT_TOP_DIR 54 | 55 | # Clone and build QT 56 | git clone $QT_GIT_URL $QT_WORKING_DIR 57 | [ $? -ne 0 ] && >&2 echo "ERROR: Unable to clone git repo $QT_GIT_URL" && exit 1 58 | pushd $QT_WORKING_DIR 59 | git checkout $QT_VERSION 60 | [ $? -ne 0 ] && >&2 echo "ERROR: Unable to checkout git revision $QT_VERSION" && exit 1 61 | perl init-repository $QT_INIT_REPOSITORY_OPTS 62 | [ $? -ne 0 ] && >&2 echo "ERROR: init-repository failed" && exit 1 63 | mkdir qt-build 64 | cd qt-build 65 | ../configure $QT_CONFIGURE_OPTS -prefix "/usr/local" 66 | [ $? -ne 0 ] && >&2 echo "ERROR: ./configure failed" && exit 1 67 | make -j $QT_J_LEVEL 68 | [ $? -ne 0 ] && >&2 echo "ERROR: make failed" && exit 1 69 | make install 70 | [ $? -ne 0 ] && >&2 echo "ERROR: make install failed" && exit 1 71 | popd 72 | 73 | # Clone and build QT Creator 74 | git clone --recursive $QT_CREATOR_GIT_URL $QT_CREATOR_WORKING_DIR 75 | [ $? -ne 0 ] && >&2 echo "ERROR: Unable to clone git repo $QT_CREATOR_GIT_URL" && exit 1 76 | pushd $QT_CREATOR_WORKING_DIR 77 | git checkout $QT_CREATOR_VERSION 78 | [ $? -ne 0 ] && >&2 echo "ERROR: Unable to checkout git revision $QT_CREATOR_VERSION" && exit 1 79 | # Make sure no submodules have the latest version, since this could 80 | # cause build errors. 81 | git submodule update --init 82 | mkdir qt-creator-build 83 | cd qt-creator-build 84 | qmake -r ../qtcreator.pro 85 | [ $? -ne 0 ] && >&2 echo "ERROR: QT creator qmake failed" && exit 1 86 | make -j $QT_J_LEVEL 87 | [ $? -ne 0 ] && >&2 echo "ERROR: QT creator make failed" && exit 1 88 | make install 89 | [ $? -ne 0 ] && >&2 echo "ERROR: QT creator make install failed" && exit 1 90 | popd 91 | 92 | popd #pushd $QT_TOP_DIR 93 | -------------------------------------------------------------------------------- /docker-build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | docker build -t erstrom/qt . 4 | -------------------------------------------------------------------------------- /docker-run-qtcreator.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | 4 | # Fix for running GUI programs from within the docker container: 5 | # 6 | # Make xorg disable access control, i.e. let any x client connect to our 7 | # server. 8 | xhost + 9 | 10 | # In order to let the container connect to the pulseaudio server over TCP, 11 | # the module-native-protocol-tcp module must be enabled: 12 | # 13 | # load-module module-native-protocol-tcp 14 | 15 | # 172.17.0.1 is the default host ip address of the docker network interface 16 | # (docker0). In case this is changed (e.g. docker container not using NAT 17 | # address) the below env var must of course be updated. 18 | PULSE_SERVER_TCP_ENV="-e PULSE_SERVER=tcp:172.17.0.1:4713" 19 | 20 | # Create the container with all options needed to let a GUI program 21 | # like qtcreator connect to the host xorg server. 22 | # The current user home directory is also mounted directly into the 23 | # container. 24 | docker run -it \ 25 | --privileged \ 26 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 27 | -v /home/`id -nu`:/home/`id -nu` \ 28 | -e DISPLAY=unix$DISPLAY \ 29 | $PULSE_SERVER_TCP_ENV \ 30 | --name qtcreator \ 31 | erstrom/qt \ 32 | qtcreator 33 | -------------------------------------------------------------------------------- /docker-run-shell.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | 4 | # Fix for running GUI programs from within the docker container: 5 | # 6 | # Make xorg disable access control, i.e. let any x client connect to our 7 | # server. 8 | xhost + 9 | 10 | # In order to let the container connect to the pulseaudio server over TCP, 11 | # the module-native-protocol-tcp module must be enabled: 12 | # 13 | # load-module module-native-protocol-tcp 14 | 15 | # 172.17.0.1 is the default host ip address of the docker network interface 16 | # (docker0). In case this is changed (e.g. docker container not using NAT 17 | # address) the below env var must of course be updated. 18 | PULSE_SERVER_TCP_ENV="-e PULSE_SERVER=tcp:172.17.0.1:4713" 19 | 20 | # Create the container with all options needed to let a GUI program 21 | # like qtcreator connect to the host xorg server. 22 | # The current user home directory is also mounted directly into the 23 | # container. 24 | docker run -it \ 25 | --privileged \ 26 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 27 | -v /home/`id -nu`:/home/`id -nu` \ 28 | -e DISPLAY=unix$DISPLAY \ 29 | $PULSE_SERVER_TCP_ENV \ 30 | --name qt-sh \ 31 | erstrom/qt 32 | -------------------------------------------------------------------------------- /docker-start-qtcreator.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # Fix for running GUI programs from within the docker container: 4 | # 5 | # Make xorg disable access control, i.e. let any x client connect to our 6 | # server. 7 | xhost + 8 | 9 | docker start qtcreator --attach --interactive 10 | -------------------------------------------------------------------------------- /docker-start-shell.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # Fix for running GUI programs from within the docker container: 4 | # 5 | # Make xorg disable access control, i.e. let any x client connect to our 6 | # server. 7 | xhost + 8 | 9 | docker start qt-sh --attach --interactive 10 | --------------------------------------------------------------------------------