blob: dd0b178ffe9cfd636f72fe0dddd0fb7f64c30564 [file] [log] [blame] [view]
James E. King, III0ad20bd2017-09-30 15:44:16 -07001# Docker Integration #
James E. King, III65efdff2017-09-25 00:13:38 -04002
James E. King, III0ad20bd2017-09-30 15:44:16 -07003Due to the large number of language requirements to build Apache Thrift, docker containers are used to build and test the project on a variety of platforms to provide maximum test coverage.
jfarrelle03f7e82015-02-18 23:25:54 -05004
James E. King, III0ad20bd2017-09-30 15:44:16 -07005## Travis CI Integration ##
jfarrelle03f7e82015-02-18 23:25:54 -05006
James E. King, III0ad20bd2017-09-30 15:44:16 -07007The Travis CI scripts use the following environment variables and logic to determine their behavior.
8
9### Environment Variables ###
10
11| Variable | Default | Usage |
12| -------- | ----- | ------- |
13| `DISTRO` | `ubuntu-xenial` | Set by various build jobs in `.travis.yml` to run builds in different containers. Not intended to be set externally.|
James E. King, IIIcd5be7b2017-10-21 10:16:19 -040014| `DOCKER_REPO` | `thrift/thrift-build` | The name of the Docker Hub repository to obtain and store docker images. |
15| `DOCKER_USER` | `<none>` | The Docker Hub account name containing the repository. |
James E. King, III0ad20bd2017-09-30 15:44:16 -070016| `DOCKER_PASS` | `<none>` | The Docker Hub account password to use when pushing new tags. |
17
James E. King, IIIcd5be7b2017-10-21 10:16:19 -040018For example, the default docker image that is used in builds if no overrides are specified would be: `thrift/thrift-build:ubuntu-xenial`
James E. King, III0ad20bd2017-09-30 15:44:16 -070019
James E. King, IIIcd5be7b2017-10-21 10:16:19 -040020### Forks ###
21
22If you have forked the Apache Thrift repository and you would like to use your own Docker Hub account to store thrift build images, you can use the Travis CI web interface to set the `DOCKER_USER`, `DOCKER_PASS`, and `DOCKER_REPO` variables in a secure manner. Your fork builds will then pull, push, and tag the docker images in your account.
James E. King, III0ad20bd2017-09-30 15:44:16 -070023
24### Logic ###
25
26The Travis CI build runs in two phases - first the docker images are rebuilt for each of the three supported containers if they do not match the Dockerfile that was used to build the most recent tag. If a `DOCKER_PASS` environment variable is specified, the docker stage builds will attempt to log into Docker Hub and push the resulting tags.
27
28## Supported Containers ##
29
30The Travis CI (continuous integration) builds use the Ubuntu Trusty, Xenial, and Artful images to maximize language level coverage.
James E. King, IIId7142b72017-09-01 13:00:36 -070031
James E. King, IIIcd5be7b2017-10-21 10:16:19 -040032### Ubuntu ###
33
James E. King, III0ad20bd2017-09-30 15:44:16 -070034* trusty (legacy)
35* xenial (stable)
36* artful (latest)
37
James E. King, IIIcd5be7b2017-10-21 10:16:19 -040038## Unsupported Containers ##
James E. King, III0ad20bd2017-09-30 15:44:16 -070039
40These containers may be in various states, and may not build everything.
jfarrelle03f7e82015-02-18 23:25:54 -050041
James E. King, IIIcd5be7b2017-10-21 10:16:19 -040042### CentOS ###
James E. King, III65efdff2017-09-25 00:13:38 -040043* 7.3
44 * make check in lib/py may hang in test_sslsocket - root cause unknown
45
James E. King, IIIcd5be7b2017-10-21 10:16:19 -040046### Debian ###
47
James E. King, III65efdff2017-09-25 00:13:38 -040048* jessie
49* stretch
50 * make check in lib/cpp fails due to https://svn.boost.org/trac10/ticket/12507
51
James E. King, IIIcfb01302017-11-11 09:39:19 -050052## Building like Travis CI does, locally ##
James E. King, IIIcd5be7b2017-10-21 10:16:19 -040053
James E. King, IIIcfb01302017-11-11 09:39:19 -050054We recommend you build locally the same way Travis CI does, so that when you submit your pull request you will run into fewer surprises. To make it a little easier, put the following into your `~/.bash_aliases` file:
jfarrelle03f7e82015-02-18 23:25:54 -050055
James E. King, IIIcfb01302017-11-11 09:39:19 -050056 # Kill all running containers.
57 alias dockerkillall='docker kill $(docker ps -q)'
jfarrelle03f7e82015-02-18 23:25:54 -050058
James E. King, IIIcfb01302017-11-11 09:39:19 -050059 # Delete all stopped containers.
60 alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker rm $(docker ps -a -q)'
jfarrelle03f7e82015-02-18 23:25:54 -050061
James E. King, IIIcfb01302017-11-11 09:39:19 -050062 # Delete all untagged images.
63 alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker rmi $(docker images -q -f dangling=true)'
jfarrelle03f7e82015-02-18 23:25:54 -050064
James E. King, IIIcfb01302017-11-11 09:39:19 -050065 # Delete all stopped containers and untagged images.
66 alias dockerclean='dockercleanc || true && dockercleani'
67
68 # Build a thrift docker image (run from top level of git repo): argument #1 is image type (ubuntu, centos, etc).
69 function dockerbuild
70 {
71 docker build -t $1 build/docker/$1
72 }
73
74 # Run a thrift docker image: argument #1 is image type (ubuntu, centos, etc).
75 function dockerrun
76 {
77 docker run -v $(pwd):/thrift/src -it $1 /bin/bash
78 }
79
80To pull down the current image being used to build (the same way Travis CI does it) - if it is out of date in any way it will build a new one for you:
81
82 thrift$ DOCKER_REPO=thrift/thrift-build DISTRO=ubuntu-xenial build/docker/refresh.sh
83
84To run all unit tests (just like Travis CI):
85
86 thrift$ dockerrun ubuntu-xenial
87 root@8caf56b0ce7b:/thrift/src# build/docker/scripts/autotools.sh
88
89To run the cross tests (just like Travis CI):
90
91 thrift$ dockerrun ubuntu-xenial
92 root@8caf56b0ce7b:/thrift/src# build/docker/scripts/cross-test.sh
93
94When you are done, you want to clean up occasionally so that docker isn't using lots of extra disk space:
95
96 thrift$ dockerclean
97
98You need to run the docker commands from the root of the git repository for them to work.
99
100When you are done in the root docker shell you can `exit` to go back to your user host shell. Once the unit tests and cross test passes locally, then submit he changes, and squash the pull request to one commit to make it easier to merge. Thanks. I am going to update the docker README.md with this information so others can leverage it too. Now you are building like Travis CI does!
101
102## Raw Commands for Building with Docker ##
103
104If you do not want to use the same scripts Travis CI does, you can do it manually:
105
106Build the image:
107
108 thrift$ docker build -t thrift build/docker/ubuntu-xenial
109
110Open a command prompt in the image:
111
112 thrift$ docker run -v $(pwd):/thrift/src -it thrift /bin/bash
jfarrelle03f7e82015-02-18 23:25:54 -0500113
James E. King, IIIcd5be7b2017-10-21 10:16:19 -0400114## Core Tool Versions per Dockerfile ##
115
116Last updated: October 1, 2017
117
James E. King, III0ad20bd2017-09-30 15:44:16 -0700118| Tool | ubuntu-trusty | ubuntu-xenial | ubuntu-artful | Notes |
119| :-------- | :------------ | :------------ | :------------ | :---- |
120| ant | 1.9.3 | 1.9.6 | 1.9.9 | |
121| autoconf | 2.69 | 2.69 | 2.69 | |
122| automake | 1.14.1 | 1.15 | 1.15 | |
123| bison | 3.0.2 | 3.0.4 | 3.0.4 | |
124| boost | 1.54.0 | 1.58.0 | 1.63.0 | artful: stock boost 1.62.0 has problems running unit tests |
125| cmake | 3.2.2 | 3.5.1 | 3.9.1 | |
126| cppcheck | 1.61 | 1.72 | 1.80 | |
127| flex | 2.5.35 | 2.6.0 | 2.6.1 | |
128| glibc | 2.19 | 2.23 | 2.26 | |
129| libevent | 2.0.21 | 2.0.21 | 2.1 | |
130| libstdc++ | 4.8.4 | 5.4.0 | 7.2.0 | |
131| make | 3.81 | 4.1 | 4.1 | |
132| openssl | 1.0.1f | 1.0.2g | 1.0.2g | |
133| qt5 | 5.2.1 | 5.5.1 | 5.9.1 | |
James E. King, IIId7142b72017-09-01 13:00:36 -0700134
James E. King, IIIcd5be7b2017-10-21 10:16:19 -0400135## Compiler/Language Versions per Dockerfile ##
136
137Last updated: October 1, 2017
138
James E. King, III0ad20bd2017-09-30 15:44:16 -0700139| Language | ubuntu-trusty | ubuntu-xenial | ubuntu-artful | Notes |
140| :-------- | :------------ | :------------ | :------------ | :---- |
141| as3 | | | | Not in CI |
142| C++ gcc | 4.8.4 | 5.4.0 | 7.2.0 | |
143| C++ clang | 3.4 | 3.8 | 4.0 | |
144| C# (mono) | 3.2.8.0 | 4.2.1 | 4.6.2.7 | |
145| c_glib | 2.40.2 | 2.48.2 | 2.54.0 | |
146| cocoa | | | | Not in CI |
147| d | 2.070.2 | 2.073.2 | 2.076.0 | |
148| dart | 1.20.1 | 1.24.2 | | artful: apt repo not compatible with apt 1.4? |
149| delphi | | | | Not in CI |
150| dotnet | | 2.0.0 | | Needs to be added to artful |
151| erlang | R16B03 | 18.3 | 20.0.4 | |
152| go | 1.2.1 | 1.6.2 | 1.8.3 | |
153| haskell | 7.6.3 | 7.10.3 | 8.0.2 | |
154| haxe | | 3.2.1 | 3.4.2 | disabled in trusty builds - cores on install v3.0.0, disabled in artful builds - see THRIFT-4352 |
155| java | 1.7.0_151 | 1.8.0_131 | 1.8.0_144 | |
156| js | | | | Unsure how to look for version info? |
157| lua | 5.1.5 | 5.2.4 | 5.3.3 | |
James E. King, III619218c2017-10-29 06:55:00 -0400158| nodejs | | 4.2.6 | 8.8.1 | trusty has node.js 0.10.0 which is too old |
James E. King, III0ad20bd2017-09-30 15:44:16 -0700159| ocaml | | 4.02.3 | 4.04.0 | |
160| perl | 5.18.2 | 5.22.1 | 5.26.0 | |
161| php | 5.5.9 | 7.0.22 | 7.1.8 | |
162| python | 2.7.6 | 2.7.12 | 2.7.14 | |
163| python3 | 3.4.3 | 3.5.2 | 3.6.3 | |
164| ruby | 1.9.3p484 | 2.3.1p112 | 2.3.3p222 | |
165| rust | 1.15.1 | 1.15.1 | 1.18.0 | |
166| smalltalk | | | | Not in CI |
167| swift | | | | Not in CI |
James E. King, IIId7142b72017-09-01 13:00:36 -0700168