| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 1 | # Docker Integration # |
| James E. King, III | 65efdff | 2017-09-25 00:13:38 -0400 | [diff] [blame] | 2 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 3 | Due to the large number of languages supported by Apache Thrift, |
| 4 | docker containers are used to build and test the project on a |
| 5 | variety of platforms to provide maximum test coverage. |
| 6 | |
| 7 | ## Appveyor Integration ## |
| 8 | |
| 9 | At this time the Appveyor scripts do not use docker containers. |
| 10 | Once Microsoft supports Visual Studio Build Tools running inside |
| 11 | nano containers (instead of Core, which is huge) then we will |
| 12 | consider using containers for the Windows builds as well. |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 13 | |
| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 14 | ## Travis CI Integration ## |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 15 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 16 | The Travis CI scripts use the following environment variables and |
| 17 | logic to determine their behavior: |
| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 18 | |
| 19 | ### Environment Variables ### |
| 20 | |
| 21 | | Variable | Default | Usage | |
| 22 | | -------- | ----- | ------- | |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 23 | | `DISTRO` | `ubuntu-focal` | Set by various build jobs in `.travis.yml` to run builds in different containers. Not intended to be set externally.| |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 24 | | `DOCKER_REPO` | `thrift/thrift-build` | The name of the Docker Hub repository to obtain and store docker images. | |
| 25 | | `DOCKER_USER` | `<none>` | The Docker Hub account name containing the repository. | |
| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 26 | | `DOCKER_PASS` | `<none>` | The Docker Hub account password to use when pushing new tags. | |
| 27 | |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 28 | For example, the default docker image that is used in builds if no overrides are specified would be: `thrift/thrift-build:ubuntu-focal` |
| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 29 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 30 | ### Forks ### |
| 31 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 32 | If you have forked the Apache Thrift repository and you would like |
| 33 | to use your own Docker Hub account to store thrift build images, |
| 34 | you can use the Travis CI web interface to set the `DOCKER_USER`, |
| 35 | `DOCKER_PASS`, and `DOCKER_REPO` variables in a secure manner. |
| 36 | Your fork builds will then pull, push, and tag the docker images |
| 37 | in your account. |
| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 38 | |
| 39 | ### Logic ### |
| 40 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 41 | The Travis CI build runs in two phases - first the docker images are rebuilt |
| 42 | for each of the supported containers if they do not match the Dockerfile that |
| 43 | was used to build the most recent tag. If a `DOCKER_PASS` environment |
| 44 | variable is specified, the docker stage builds will attempt to log into |
| 45 | Docker Hub and push the resulting tags. |
| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 46 | |
| 47 | ## Supported Containers ## |
| 48 | |
| Jens Geyer | 94e1a30 | 2025-05-15 21:30:12 +0200 | [diff] [blame] | 49 | The Travis CI (continuous integration) builds use the Ubuntu Noble (24.04 LTS), |
| 50 | Jammy (22.04 LTS) and Focal (20.04 LTS) images to maximize language level |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 51 | coverage. |
| James E. King, III | d7142b7 | 2017-09-01 13:00:36 -0700 | [diff] [blame] | 52 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 53 | ### Ubuntu ### |
| 54 | |
| Jens Geyer | 94e1a30 | 2025-05-15 21:30:12 +0200 | [diff] [blame] | 55 | * focal (stable) |
| 56 | * jammy (stable) |
| 57 | * noble (next stable) |
| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 58 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 59 | ## Unsupported Containers ## |
| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 60 | |
| 61 | These containers may be in various states, and may not build everything. |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 62 | They can be found in the `old/` subdirectory. |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 63 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 64 | ### CentOS ### |
| James E. King, III | 65efdff | 2017-09-25 00:13:38 -0400 | [diff] [blame] | 65 | * 7.3 |
| 66 | * make check in lib/py may hang in test_sslsocket - root cause unknown |
| 67 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 68 | ### Debian ### |
| 69 | |
| James E. King, III | 65efdff | 2017-09-25 00:13:38 -0400 | [diff] [blame] | 70 | * jessie |
| 71 | * stretch |
| 72 | * make check in lib/cpp fails due to https://svn.boost.org/trac10/ticket/12507 |
| 73 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 74 | ## Building like Travis CI does, locally ## |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 75 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 76 | We recommend you build locally the same way Travis CI does, so that when you |
| 77 | submit your pull request you will run into fewer surprises. To make it a |
| 78 | little easier, put the following into your `~/.bash_aliases` file: |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 79 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 80 | # Kill all running containers. |
| 81 | alias dockerkillall='docker kill $(docker ps -q)' |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 82 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 83 | # Delete all stopped containers. |
| 84 | alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)' |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 85 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 86 | # Delete all untagged images. |
| 87 | alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)' |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 88 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 89 | # Delete all stopped containers and untagged images. |
| 90 | alias dockerclean='dockercleanc || true && dockercleani' |
| 91 | |
| 92 | # Build a thrift docker image (run from top level of git repo): argument #1 is image type (ubuntu, centos, etc). |
| 93 | function dockerbuild |
| 94 | { |
| 95 | docker build -t $1 build/docker/$1 |
| 96 | } |
| 97 | |
| 98 | # Run a thrift docker image: argument #1 is image type (ubuntu, centos, etc). |
| 99 | function dockerrun |
| 100 | { |
| 101 | docker run -v $(pwd):/thrift/src -it $1 /bin/bash |
| 102 | } |
| 103 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 104 | Then, to pull down the current image being used to build (the same way |
| 105 | Travis CI does it) - if it is out of date in any way it will build a |
| 106 | new one for you: |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 107 | |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 108 | thrift$ DOCKER_REPO=thrift/thrift-build DISTRO=ubuntu-focal build/docker/refresh.sh |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 109 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 110 | To run all unit tests (just like Travis CI does): |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 111 | |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 112 | thrift$ dockerrun thrift/thrift-build:ubuntu-focal |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 113 | root@8caf56b0ce7b:/thrift/src# build/docker/scripts/autotools.sh |
| 114 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 115 | To run the cross tests (just like Travis CI does): |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 116 | |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 117 | thrift$ dockerrun thrift/thrift-build:ubuntu-focal |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 118 | root@8caf56b0ce7b:/thrift/src# build/docker/scripts/cross-test.sh |
| 119 | |
| 120 | When you are done, you want to clean up occasionally so that docker isn't using lots of extra disk space: |
| 121 | |
| 122 | thrift$ dockerclean |
| 123 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 124 | You need to run the docker commands from the root of the local clone of the |
| 125 | thrift git repository for them to work. |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 126 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 127 | When you are done in the root docker shell you can `exit` to go back to |
| 128 | your user host shell. Once the unit tests and cross test passes locally, |
| 129 | submit the changes, and if desired squash the pull request to one commit |
| 130 | to make it easier to merge (the committers can squash at commit time now |
| 131 | that GitHub is the master repository). Now you are building like Travis CI does! |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 132 | |
| 133 | ## Raw Commands for Building with Docker ## |
| 134 | |
| 135 | If you do not want to use the same scripts Travis CI does, you can do it manually: |
| 136 | |
| 137 | Build the image: |
| 138 | |
| thomasbruggink | 5d0205d | 2024-11-05 15:33:18 +0900 | [diff] [blame] | 139 | Linux: |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 140 | |
| 141 | thrift$ docker build --build-arg uid=$(id -u) --build-arg gid=$(id -g) -t thrift build/docker/ubuntu-jammy |
| 142 | |
| thomasbruggink | 5d0205d | 2024-11-05 15:33:18 +0900 | [diff] [blame] | 143 | Windows/Mac: |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 144 | |
| 145 | thrift$ docker build -t thrift build/docker/ubuntu-jammy |
| 146 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 147 | |
| 148 | Open a command prompt in the image: |
| 149 | |
| 150 | thrift$ docker run -v $(pwd):/thrift/src -it thrift /bin/bash |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 151 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 152 | ## Core Tool Versions per Dockerfile ## |
| 153 | |
| Thomas | f843185 | 2024-03-05 23:21:05 +0900 | [diff] [blame] | 154 | Last updated: March 5, 2024 |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 155 | |
| Jens Geyer | 94e1a30 | 2025-05-15 21:30:12 +0200 | [diff] [blame] | 156 | | Tool | ubuntu-focal | ubuntu-jammy | ubuntu-noble | Notes | |
| 157 | | :-------- | :------------ | :------------ | :------------ | :---- | |
| 158 | | ant | 1.10.7 | 1.10.12 | | | |
| 159 | | autoconf | 2.69 | 2.71 | | | |
| 160 | | automake | 1.16.1 | 1.16.5 | | | |
| 161 | | bison | 3.5.1 | 3.8.2 | | | |
| 162 | | boost | 1.71.0 | 1.74.0 | | | |
| 163 | | cmake | 3.16.3 | 3.22.1 | | | |
| 164 | | cppcheck | 1.90 | 2.7 | | | |
| 165 | | flex | 2.6.4 | 2.6.4 | | | |
| 166 | | libc6 | 2.31 | 2.35 | | glibc | |
| 167 | | libevent | 2.0.16 | 2.0.16 | | | |
| 168 | | libstdc++ | 10.5.0 | 10.5.0 | | | |
| 169 | | make | 4.2.1 | 4.3 | | | |
| 170 | | openssl | 1.1.1f | 3.0.2 | | | |
| 171 | | qt5 | 5.12.8 | 5.15.3 | | | |
| James E. King, III | d7142b7 | 2017-09-01 13:00:36 -0700 | [diff] [blame] | 172 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 173 | ## Compiler/Language Versions per Dockerfile ## |
| 174 | |
| Jens Geyer | 94e1a30 | 2025-05-15 21:30:12 +0200 | [diff] [blame] | 175 | | Tool | ubuntu-focal | ubuntu-jammy | ubuntu-noble | Notes | |
| 176 | | :-------- | :------------ | :------------ | :------------ | :---- | |
| 177 | | as of | Mar 06, 2018 | Jul 1, 2019 | | | |
| 178 | | as3 | 4.6.0 | 4.6.0 | | | |
| 179 | | C++ gcc | 9.4.0 | 11.4.0 | | | |
| 180 | | C++ clang | 13.0.0 | 13.0.0 | | | |
| 181 | | c\_glib | 3.2.12 | 3.2.12 | | | |
| 182 | | cl (sbcl) | | 1.5.3 | | | |
| 183 | | d | 2.087.0 | 2.087.0 | | | |
| 184 | | dart | 2.7.2-1 | 2.7.2-1 | | | |
| 185 | | delphi | | | | Not in CI | |
| 186 | | erlang | OTP-25.3.2.9 | OTP-25.3.2.9 | | | |
| 187 | | go | 1.21.7 | 1.21.7 | | | |
| 188 | | haxe | 4.2.1 | 4.2.1 | | | |
| 189 | | java | 17 | 17 | | | |
| 190 | | js | Node.js 16.20.2, npm 8.19.4 | | | Node.js 16.20.2, npm 8.19.4 | |
| 191 | | lua | 5.2.4 | 5.2.4 | | Lua 5.3: see THRIFT-4386 | |
| 192 | | netstd | 9.0 | 9.0 | 9.0 | | |
| 193 | | nodejs | 16.20.2 | 16.20.2 | | | |
| 194 | | ocaml | 4.08.1 | 4.13.1 | | | |
| 195 | | perl | 5.30.0 | 5.34.0 | | | |
| 196 | | php | 7.4.3 | 8.1.2 | 8.3 | | |
| 197 | | python2 | 2.7.18 | | | | |
| 198 | | python3 | 3.8.10 | 3.10.12 | | | |
| 199 | | ruby | 2.7.0p0 | 3.0.2p107 | | | |
| 200 | | rust | 1.83.0 | 1.83.0 | | | |
| 201 | | smalltalk | | | | Not in CI | |
| 202 | | swift | 5.7 | 5.7 | 6.1 | | |