| 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 | |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 49 | The Travis CI (continuous integration) builds use the Ubuntu Jammy |
| 50 | (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 | |
| Jiayu Liu | 1d61fe1 | 2022-10-10 08:45:10 +0800 | [diff] [blame] | 55 | * focal (stable, current) |
| Jiayu Liu | 1d61fe1 | 2022-10-10 08:45:10 +0800 | [diff] [blame] | 56 | * jammy (next stable, WIP) |
| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 57 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 58 | ## Unsupported Containers ## |
| James E. King, III | 0ad20bd | 2017-09-30 15:44:16 -0700 | [diff] [blame] | 59 | |
| 60 | 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] | 61 | They can be found in the `old/` subdirectory. |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 62 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 63 | ### CentOS ### |
| James E. King, III | 65efdff | 2017-09-25 00:13:38 -0400 | [diff] [blame] | 64 | * 7.3 |
| 65 | * make check in lib/py may hang in test_sslsocket - root cause unknown |
| 66 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 67 | ### Debian ### |
| 68 | |
| James E. King, III | 65efdff | 2017-09-25 00:13:38 -0400 | [diff] [blame] | 69 | * jessie |
| 70 | * stretch |
| 71 | * make check in lib/cpp fails due to https://svn.boost.org/trac10/ticket/12507 |
| 72 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 73 | ## Building like Travis CI does, locally ## |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 74 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 75 | We recommend you build locally the same way Travis CI does, so that when you |
| 76 | submit your pull request you will run into fewer surprises. To make it a |
| 77 | little easier, put the following into your `~/.bash_aliases` file: |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 78 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 79 | # Kill all running containers. |
| 80 | alias dockerkillall='docker kill $(docker ps -q)' |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 81 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 82 | # Delete all stopped containers. |
| 83 | 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] | 84 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 85 | # Delete all untagged images. |
| 86 | 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] | 87 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 88 | # Delete all stopped containers and untagged images. |
| 89 | alias dockerclean='dockercleanc || true && dockercleani' |
| 90 | |
| 91 | # Build a thrift docker image (run from top level of git repo): argument #1 is image type (ubuntu, centos, etc). |
| 92 | function dockerbuild |
| 93 | { |
| 94 | docker build -t $1 build/docker/$1 |
| 95 | } |
| 96 | |
| 97 | # Run a thrift docker image: argument #1 is image type (ubuntu, centos, etc). |
| 98 | function dockerrun |
| 99 | { |
| 100 | docker run -v $(pwd):/thrift/src -it $1 /bin/bash |
| 101 | } |
| 102 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 103 | Then, to pull down the current image being used to build (the same way |
| 104 | Travis CI does it) - if it is out of date in any way it will build a |
| 105 | new one for you: |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 106 | |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 107 | 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] | 108 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 109 | To run all unit tests (just like Travis CI does): |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 110 | |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 111 | thrift$ dockerrun thrift/thrift-build:ubuntu-focal |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 112 | root@8caf56b0ce7b:/thrift/src# build/docker/scripts/autotools.sh |
| 113 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 114 | To run the cross tests (just like Travis CI does): |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 115 | |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 116 | thrift$ dockerrun thrift/thrift-build:ubuntu-focal |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 117 | root@8caf56b0ce7b:/thrift/src# build/docker/scripts/cross-test.sh |
| 118 | |
| 119 | When you are done, you want to clean up occasionally so that docker isn't using lots of extra disk space: |
| 120 | |
| 121 | thrift$ dockerclean |
| 122 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 123 | You need to run the docker commands from the root of the local clone of the |
| 124 | thrift git repository for them to work. |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 125 | |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 126 | When you are done in the root docker shell you can `exit` to go back to |
| 127 | your user host shell. Once the unit tests and cross test passes locally, |
| 128 | submit the changes, and if desired squash the pull request to one commit |
| 129 | to make it easier to merge (the committers can squash at commit time now |
| 130 | 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] | 131 | |
| 132 | ## Raw Commands for Building with Docker ## |
| 133 | |
| 134 | If you do not want to use the same scripts Travis CI does, you can do it manually: |
| 135 | |
| 136 | Build the image: |
| 137 | |
| thomasbruggink | 5d0205d | 2024-11-05 15:33:18 +0900 | [diff] [blame] | 138 | Linux: |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 139 | |
| 140 | thrift$ docker build --build-arg uid=$(id -u) --build-arg gid=$(id -g) -t thrift build/docker/ubuntu-jammy |
| 141 | |
| thomasbruggink | 5d0205d | 2024-11-05 15:33:18 +0900 | [diff] [blame] | 142 | Windows/Mac: |
| Thomas | c890ed4 | 2024-02-25 19:58:30 +0900 | [diff] [blame] | 143 | |
| 144 | thrift$ docker build -t thrift build/docker/ubuntu-jammy |
| 145 | |
| James E. King, III | cfb0130 | 2017-11-11 09:39:19 -0500 | [diff] [blame] | 146 | |
| 147 | Open a command prompt in the image: |
| 148 | |
| 149 | thrift$ docker run -v $(pwd):/thrift/src -it thrift /bin/bash |
| jfarrell | e03f7e8 | 2015-02-18 23:25:54 -0500 | [diff] [blame] | 150 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 151 | ## Core Tool Versions per Dockerfile ## |
| 152 | |
| Thomas | f843185 | 2024-03-05 23:21:05 +0900 | [diff] [blame] | 153 | Last updated: March 5, 2024 |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 154 | |
| Thomas | f843185 | 2024-03-05 23:21:05 +0900 | [diff] [blame] | 155 | | Tool | ubuntu-focal | ubuntu-jammy | Notes | |
| James E. King III | a37feaf | 2018-03-06 15:11:01 -0500 | [diff] [blame] | 156 | | :-------- | :------------ | :------------ | :---- | |
| Thomas | f843185 | 2024-03-05 23:21:05 +0900 | [diff] [blame] | 157 | | ant | 1.10.7 | 1.10.12 | | |
| 158 | | autoconf | 2.69 | 2.71 | | |
| 159 | | automake | 1.16.1 | 1.16.5 | | |
| 160 | | bison | 3.5.1 | 3.8.2 | | |
| 161 | | boost | 1.71.0 | 1.74.0 | | |
| 162 | | cmake | 3.16.3 | 3.22.1 | | |
| 163 | | cppcheck | 1.90 | 2.7 | | |
| 164 | | flex | 2.6.4 | 2.6.4 | | |
| 165 | | libc6 | 2.31 | 2.35 | glibc | |
| 166 | | libevent | 2.0.16 | 2.0.16 | | |
| 167 | | libstdc++ | 10.5.0 | 10.5.0 | | |
| 168 | | make | 4.2.1 | 4.3 | | |
| 169 | | openssl | 1.1.1f | 3.0.2 | | |
| 170 | | qt5 | 5.12.8 | 5.15.3 | | |
| James E. King, III | d7142b7 | 2017-09-01 13:00:36 -0700 | [diff] [blame] | 171 | |
| James E. King, III | cd5be7b | 2017-10-21 10:16:19 -0400 | [diff] [blame] | 172 | ## Compiler/Language Versions per Dockerfile ## |
| 173 | |
| Thomas | f843185 | 2024-03-05 23:21:05 +0900 | [diff] [blame] | 174 | | Language | ubuntu-focal | ubuntu-jammy | Notes | |
| James E. King III | a37feaf | 2018-03-06 15:11:01 -0500 | [diff] [blame] | 175 | | :-------- | :------------ | :------------ | :---- | |
| James E. King III | 93ff9b0 | 2019-06-21 17:50:34 -0400 | [diff] [blame] | 176 | | as of | Mar 06, 2018 | Jul 1, 2019 | | |
| Thomas | f843185 | 2024-03-05 23:21:05 +0900 | [diff] [blame] | 177 | | as3 | 4.6.0 | 4.6.0 | | |
| 178 | | C++ gcc | 9.4.0 | 11.4.0 | | |
| 179 | | C++ clang | 13.0.0 | 13.0.0 | | |
| 180 | | c\_glib | 3.2.12 | 3.2.12 | | |
| Max-Gerd Retzlaff | 04057ac | 2022-08-23 17:38:34 +0200 | [diff] [blame] | 181 | | cl (sbcl) | | 1.5.3 | | |
| James Lacey | 7054b31 | 2021-03-26 11:38:38 -0700 | [diff] [blame] | 182 | | d | 2.087.0 | 2.087.0 | | |
| Thomas | f843185 | 2024-03-05 23:21:05 +0900 | [diff] [blame] | 183 | | dart | 2.7.2-1 | 2.7.2-1 | | |
| James E. King III | a37feaf | 2018-03-06 15:11:01 -0500 | [diff] [blame] | 184 | | delphi | | | Not in CI | |
| Thomas | f843185 | 2024-03-05 23:21:05 +0900 | [diff] [blame] | 185 | | erlang | OTP-25.3.2.9 | OTP-25.3.2.9 | | |
| 186 | | go | 1.21.7 | 1.21.7 | | |
| 187 | | haxe | 4.2.1 | 4.2.1 | | |
| 188 | | java | 17 | 17 | | |
| 189 | | js | Node.js 16.20.2, npm 8.19.4 | Node.js 16.20.2, npm 8.19.4 | | |
| 190 | | lua | 5.2.4 | 5.2.4 | Lua 5.3: see THRIFT-4386 | |
| Jens Geyer | e26b4a8 | 2024-11-12 23:53:04 +0100 | [diff] [blame] | 191 | | netstd | 9.0 | 9.0 | | |
| Thomas | f843185 | 2024-03-05 23:21:05 +0900 | [diff] [blame] | 192 | | nodejs | 16.20.2 | 16.20.2 | | |
| 193 | | ocaml | 4.08.1 | 4.13.1 | | |
| 194 | | perl | 5.30.0 | 5.34.0 | | |
| 195 | | php | 7.4.3 | 8.1.2 | | |
| 196 | | python2 | 2.7.18 | | | |
| 197 | | python3 | 3.8.10 | 3.10.12 | | |
| 198 | | ruby | 2.7.0p0 | 3.0.2p107 | | |
| Cameron Martin | da54fc8 | 2025-01-12 08:55:45 +0000 | [diff] [blame] | 199 | | rust | 1.83.0 | 1.83.0 | | |
| James E. King III | a37feaf | 2018-03-06 15:11:01 -0500 | [diff] [blame] | 200 | | smalltalk | | | Not in CI | |
| Thomas | f843185 | 2024-03-05 23:21:05 +0900 | [diff] [blame] | 201 | | swift | 5.7 | 5.7 | | |