Skip to content

Commit bd71e59

Browse files
committed
reference build environment w/ docker
1 parent 714e4c7 commit bd71e59

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+

Dockerfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM java:8
2+
3+
RUN wget -q https://services.gradle.org/distributions/gradle-2.12-bin.zip \
4+
&& unzip -q gradle-2.12-bin.zip -d /opt \
5+
&& rm gradle-2.12-bin.zip
6+
7+
ENV GRADLE_HOME /opt/gradle-2.12
8+
ENV PATH $GRADLE_HOME/bin:$PATH
9+
10+
# Prepare a user account for use at runtime. boot2docker uses uid 1000.
11+
RUN useradd --uid 1000 -m vagrant
12+
USER vagrant
13+
WORKDIR /home/vagrant
14+
15+
CMD ["bash"]

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,53 @@ gradle -Pskipbench check # Executes the tests w/o running the benchmarks
111111

112112
**Linux Gradle Issues?** [see the wiki here.](https://github.com/numenta/htm.java/wiki/Gradle---JAVA_HOME-Issue-Resolution)
113113

114+
115+
## Reference Build Environment
116+
As a convenience to developers, we provide a docker image with the needed software to build the HTM.java library from sources. This approach relies on the [Docker Toolbox](https://www.docker.com/products/docker-toolbox), which is installable on Mac and Windows.
117+
118+
Below we'll use a technique to share your cloned HTM.java sources from your project folder into a docker container, then build the library with `gradle`. The build outputs are written back to your project folder, not isolated within the container.
119+
120+
### Install Docker Toolbox
121+
Follow the instructions on the toolbox site, then open the quickstart terminal. You should adjust the memory settings on the toolbox VM, because the default (2GB) is insufficient for the HTM.java test suite.
122+
123+
```
124+
[htm.java]$ docker-machine rm default
125+
About to remove default
126+
Are you sure? (y/n): y
127+
128+
[htm.java]$ docker-machine create -d virtualbox --virtualbox-memory 4096 default
129+
...
130+
```
131+
132+
### Build the Docker Image
133+
The docker image, which you simply build once, contains OpenJDK 8 and Gradle. It doesn't contain any HTM.java source code; when we later run the container, the source code is read directly from your project folder.
134+
135+
```
136+
[htm.java]$ docker build -t $USER/htm.java .
137+
...
138+
Successfully built <IMAGE ID>
139+
```
140+
141+
### Run the Container
142+
Run a container based on the docker image, which launches a bash shell where you'll fire up gradle.
143+
144+
```
145+
[htm.java]$ docker run -it --rm -v `pwd`:/home/vagrant/htm.java $USER/htm.java
146+
```
147+
148+
Notice that the current directory (which should be your HTM.java project folder) is shared into the container, as `/home/vagrant/htm.java`.
149+
150+
### Build
151+
Build the project as usual.
152+
```
153+
vagrant@96e54fd78012:~$ cd /home/vagrant/htm.java
154+
vagrant@96e54fd78012:~/htm.java$ gradle -Pskipbench check
155+
...
156+
BUILD SUCCESSFUL
157+
158+
vagrant@96e54fd78012:~/htm.java$ exit
159+
```
160+
114161
## Project Integration (New)
115162
For tips and insights on how to use the Network API to add HTM's into your own applications, see:
116163

0 commit comments

Comments
 (0)