README.md
1# Docker Integration #
2
3Due to the large number of languages supported by Apache Thrift,
4docker containers are used to build and test the project on a
5variety of platforms to provide maximum test coverage.
6
7## Appveyor Integration ##
8
9At this time the Appveyor scripts do not use docker containers.
10Once Microsoft supports Visual Studio Build Tools running inside
11nano containers (instead of Core, which is huge) then we will
12consider using containers for the Windows builds as well.
13
14## Travis CI Integration ##
15
16The Travis CI scripts use the following environment variables and
17logic to determine their behavior:
18
19### Environment Variables ###
20
21| Variable | Default | Usage |
22| -------- | ----- | ------- |
23| `DISTRO` | `ubuntu-bionic` | Set by various build jobs in `.travis.yml` to run builds in different containers. Not intended to be set externally.|
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. |
26| `DOCKER_PASS` | `<none>` | The Docker Hub account password to use when pushing new tags. |
27
28For example, the default docker image that is used in builds if no overrides are specified would be: `thrift/thrift-build:ubuntu-bionic`
29
30### Forks ###
31
32If you have forked the Apache Thrift repository and you would like
33to use your own Docker Hub account to store thrift build images,
34you can use the Travis CI web interface to set the `DOCKER_USER`,
35`DOCKER_PASS`, and `DOCKER_REPO` variables in a secure manner.
36Your fork builds will then pull, push, and tag the docker images
37in your account.
38
39### Logic ###
40
41The Travis CI build runs in two phases - first the docker images are rebuilt
42for each of the supported containers if they do not match the Dockerfile that
43was used to build the most recent tag. If a `DOCKER_PASS` environment
44variable is specified, the docker stage builds will attempt to log into
45Docker Hub and push the resulting tags.
46
47## Supported Containers ##
48
49The Travis CI (continuous integration) builds use the Ubuntu Bionic
50(18.04 LTS) and Xenial (16.04 LTS) images to maximize language level
51coverage.
52
53### Ubuntu ###
54
55* focal (stable, current)
56* bionic (previous stable)
57* jammy (next stable, WIP)
58
59## Unsupported Containers ##
60
61These containers may be in various states, and may not build everything.
62They can be found in the `old/` subdirectory.
63
64### CentOS ###
65* 7.3
66 * make check in lib/py may hang in test_sslsocket - root cause unknown
67
68### Debian ###
69
70* jessie
71* stretch
72 * make check in lib/cpp fails due to https://svn.boost.org/trac10/ticket/12507
73
74## Building like Travis CI does, locally ##
75
76We recommend you build locally the same way Travis CI does, so that when you
77submit your pull request you will run into fewer surprises. To make it a
78little easier, put the following into your `~/.bash_aliases` file:
79
80 # Kill all running containers.
81 alias dockerkillall='docker kill $(docker ps -q)'
82
83 # Delete all stopped containers.
84 alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)'
85
86 # Delete all untagged images.
87 alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)'
88
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
104Then, to pull down the current image being used to build (the same way
105Travis CI does it) - if it is out of date in any way it will build a
106new one for you:
107
108 thrift$ DOCKER_REPO=thrift/thrift-build DISTRO=ubuntu-bionic build/docker/refresh.sh
109
110To run all unit tests (just like Travis CI does):
111
112 thrift$ dockerrun thrift/thrift-build:ubuntu-bionic
113 root@8caf56b0ce7b:/thrift/src# build/docker/scripts/autotools.sh
114
115To run the cross tests (just like Travis CI does):
116
117 thrift$ dockerrun thrift/thrift-build:ubuntu-bionic
118 root@8caf56b0ce7b:/thrift/src# build/docker/scripts/cross-test.sh
119
120When 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
124You need to run the docker commands from the root of the local clone of the
125thrift git repository for them to work.
126
127When you are done in the root docker shell you can `exit` to go back to
128your user host shell. Once the unit tests and cross test passes locally,
129submit the changes, and if desired squash the pull request to one commit
130to make it easier to merge (the committers can squash at commit time now
131that GitHub is the master repository). Now you are building like Travis CI does!
132
133## Raw Commands for Building with Docker ##
134
135If you do not want to use the same scripts Travis CI does, you can do it manually:
136
137Build the image:
138
139 thrift$ docker build -t thrift build/docker/ubuntu-bionic
140
141Open a command prompt in the image:
142
143 thrift$ docker run -v $(pwd):/thrift/src -it thrift /bin/bash
144
145## Core Tool Versions per Dockerfile ##
146
147Last updated: October 1, 2017
148
149| Tool | ubuntu-xenial | ubuntu-bionic | Notes |
150| :-------- | :------------ | :------------ | :---- |
151| ant | 1.9.6 | 1.10.3 | |
152| autoconf | 2.69 | 2.69 | |
153| automake | 1.15 | 1.15.1 | |
154| bison | 3.0.4 | 3.0.4 | |
155| boost | 1.58.0 | 1.65.1 | |
156| cmake | 3.5.1 | 3.10.2 | |
157| cppcheck | 1.72 | 1.82 | |
158| flex | 2.6.0 | 2.6.4 | |
159| libc6 | 2.23 | 2.27 | glibc |
160| libevent | 2.0.21 | 2.1.8 | |
161| libstdc++ | 5.4.0 | 7.3.0 | |
162| make | 4.1 | 4.1 | |
163| openssl | 1.0.2g | 1.1.0g | |
164| qt5 | 5.5.1 | 5.9.5 | |
165
166## Compiler/Language Versions per Dockerfile ##
167
168| Language | ubuntu-xenial | ubuntu-bionic | Notes |
169| :-------- | :------------ | :------------ | :---- |
170| as of | Mar 06, 2018 | Jul 1, 2019 | |
171| as3 | | 4.6.0 | |
172| C++ gcc | 5.4.0 | 7.4.0 | |
173| C++ clang | 3.8 | 6.0 | |
174| C# (mono) | 4.2.1.0 | 4.6.2.7 | |
175| c\_glib | 2.48.2 | 2.56.4 | |
176| cl (sbcl) | | 1.5.3 | |
177| d | 2.087.0 | 2.087.0 | |
178| dart | 2.0.0 | 2.4.0 | |
179| delphi | | | Not in CI |
180| erlang | OTP-18 | OTP-23 | |
181| go | 1.15.10 | 1.16.2 | |
182| haxe | 3.2.1 | 3.4.4 | THRIFT-4352: avoid 3.4.2 |
183| java | 1.8.0\_191 | 17 | |
184| js | Node.js 6.17.1, V8 5.1.281.111, npm 3.10.10 | Node.js 10.18.0, V8 6.8.275.32, npm 6.13.4 | |
185| lua | | 5.2.4 | Lua 5.3: see THRIFT-4386 |
186| netstd | 6.0 | 6.0 | |
187| nodejs | 6.16.0 | 10.16.0 | |
188| ocaml | | 4.05.0 | THRIFT-4517: ocaml 4.02.3 on xenial appears broken |
189| perl | 5.22.1 | 5.26.1 | |
190| php | 7.0.32 | 7.2.19 | |
191| python | 2.7.12 | 2.7.15 | |
192| python3 | 3.5.2 | 3.6.8 | |
193| ruby | 2.3.1p112 | 2.5.1p57 | |
194| rust | 1.61.0 | 1.61.0 | |
195| smalltalk | | | Not in CI |
196| swift | | 5.1.4 | |
197