Skip to content

Commit 8fa7f8e

Browse files
authored
Merge pull request #25 from lesserwhirls/java
Various Improvements
2 parents dc7c9a6 + daeeb3e commit 8fa7f8e

File tree

17 files changed

+110
-189
lines changed

17 files changed

+110
-189
lines changed

README.md

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ packer build --only=<type> thredds-test-env.pkr.hcl
3636
~~~
3737

3838
`<type>` will one or more (separated by commas) of the following:
39-
* `docker.docker-jenkins`: Provision a Docker container and generate and tag a local Docker image (`docker.unidata.ucar.edu/thredds-test-environment:latest`).
39+
* `docker.docker-jenkins`: Provision a Docker container and generate and tag a local Docker image (`docker.unidata.ucar.edu/thredds-test-environment:20.04`).
4040
* `docker.docker-github-action`: Provision a Docker container for use with GitHub Actions and tag a local docker image (`ghcr.io/unidata/thredds-test-action:v3`).
4141
* `docker.docker-export`: Provision a Docker container and generate a local Docker image as a file (`image.tar`).
4242

@@ -46,24 +46,24 @@ Typically, we would run the following to update the Jenkins and Github Action Do
4646
packer build --only=docker.docker-jenkins,docker.docker-github-action thredds-test-env.pkr.hcl
4747
~~~
4848

49-
The Docker image builds takes about 1 hour to create.
49+
The Docker image builds takes about 30 minutes to create on MacOS.
5050
Packer will run the builders in parallel, so the total time to create the `thredds-test-environment` images is around an hour.
5151

5252
If using `docker-jenkins`, then once the image is built you can test out the environment by using:
5353

5454
~~~bash
55-
docker run -i -t --rm docker.unidata.ucar.edu/thredds-test-environment:latest
55+
docker run -i -t --rm docker.unidata.ucar.edu/thredds-test-environment:24.04
5656
~~~
5757

58-
These images are not produced using the multiplatform feature of Docker.
59-
If you are on a arm64 based mac, you will need to run:
58+
These images are built using the multiplatform feature of Docker, and only `linux/amd64` images are produced.
59+
If you are on a `arm64` based mac, you will need to run:
6060

6161
~~~bash
62-
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run -i -t --rm docker.unidata.ucar.edu/thredds-test-environment:latest
62+
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run -i -t --rm docker.unidata.ucar.edu/thredds-test-environment:24.04
6363
~~~
6464

6565
Note that images are not pushed as part of this build process.
66-
Pushes can be done via the normal docker mechanisms, e.g. `docker image push docker.unidata.ucar.edu/thredds-test-environment:latest` and `docker image push ghcr.io/unidata/thredds-test-action:v3`.
66+
Pushes can be done via the normal docker mechanisms, e.g. `docker image push docker.unidata.ucar.edu/thredds-test-environment:24.04` and `docker image push ghcr.io/unidata/thredds-test-action:v3`.
6767

6868
## Project layout
6969

@@ -92,12 +92,11 @@ The `ansible/` directory is laid out as follows:
9292
We use the following roles when provisioning our images:
9393

9494
* `cleanup`: General cleanup related tasks, such as remove the temporary build directory and running `ldconfig`
95+
* `corretto`: Obtain and install LTS versions of Corretto.
9596
* `general-packages`: Install general packages needed for the build environment using the OS package manager.
96-
* `gradle-builds-cache-bootstrap`: Pull in and build netCDF-Java to populate the gradle cache for user ubuntu.
9797
* `init`: Initialize the build environment by ensuring the temporary ansible build directory exists.
9898
* `libnetcdf-and-deps`: Configure, build, and install `zlib`, `HDF5`, and `netCDF-C`.
9999
* `maven`: Obtain and install the Apache Maven software project management and comprehension tool.
100-
* `miniconda`: Obtain and install the Anaconda miniconda python distribution.
101100
* `security`:
102101
* Add the `ubuntu` user.
103102
* Add a default `maven-settings.xml` file configured to publish to the Unidata artifacts server.
@@ -107,8 +106,6 @@ We use the following roles when provisioning our images:
107106
* `test-data-mount-prep`: Prepare the environment to mount the `thredds-test-data` datasets when available (currently used on Jenkins worker nodes).
108107
* `zulu`: Obtain and install LTS versions of Zulu.
109108

110-
We also use a role from [Ansible Galaxy](https://galaxy.ansible.com/) to setup a Ruby environment ([geerlingguy.ruby](https://galaxy.ansible.com/geerlingguy/ruby)).
111-
112109
## THREDDS Test Environment Highlights
113110

114111
### netCDF-C
@@ -118,10 +115,6 @@ We also use a role from [Ansible Galaxy](https://galaxy.ansible.com/) to setup a
118115
* zlib version: `1.2.11`
119116
* hdf5 version: `1.12.1`
120117

121-
### miniconda
122-
* location: `/usr/thredds-test-environment/miniconda3`
123-
* version: `Miniconda3-latest-Linux-x86_64`
124-
125118
### maven:
126119
* location: `/usr/thredds-test-environment/mvn`
127120
* version: `3.6.3`
@@ -139,12 +132,14 @@ We also use a role from [Ansible Galaxy](https://galaxy.ansible.com/) to setup a
139132
* 17 (`/usr/thredds-test-environment/zulu17`)
140133
* 21 (`/usr/thredds-test-environment/zulu21`)
141134

142-
### Ruby
143-
* ruby (via [geerlingguy.ruby](https://galaxy.ansible.com/geerlingguy/ruby) from [Ansible Galaxy](https://galaxy.ansible.com/))
135+
* Corretto (latest version available from docs.aws.amazon.com/corretto/)
136+
* 8 (`/usr/thredds-test-environment/corretto8`)
137+
* 11 (`/usr/thredds-test-environment/corretto11`)
138+
* 17 (`/usr/thredds-test-environment/corretto17`)
139+
* 21 (`/usr/thredds-test-environment/corretto21`)
144140

145141
### Bash functions:
146-
* `select-java <vendor> <version>` (where version is 8, 11, 17, or 21, and vendor is `temurin` or `zulu`)
147-
* `activate-conda`
142+
* `select-java <vendor> <version>` (where version is 8, 11, 17, or 21, and vendor is `temurin`, `zulu`, or `corretto`)
148143
* `get_pw <key>`
149144

150145
### Latest version available via the OS Package Manager
@@ -160,26 +155,26 @@ We also use a role from [Ansible Galaxy](https://galaxy.ansible.com/) to setup a
160155
### Docker Image
161156

162157
~~~
163-
docker.docker-jenkins: Friday 22 November 2024 21:12:32 +0000 (0:00:02.871) 0:20:20.107 *******
158+
docker.docker-jenkins: Tuesday 25 February 2025 15:28:53 +0000 (0:00:02.993) 0:25:00.302 ******
164159
docker.docker-jenkins: ===============================================================================
165-
docker.docker-jenkins: Wait for the HDF5 async test task to complete. ------------------------ 362.21s
166-
docker.docker-jenkins: libnetcdf-and-deps : Install hdf5. ------------------------------------ 272.84s
167-
docker.docker-jenkins: libnetcdf-and-deps : Configure netCDF-c. ------------------------------ 128.28s
168-
docker.docker-jenkins: libnetcdf-and-deps : Configure hdf5. ---------------------------------- 114.44s
169-
docker.docker-jenkins: zulu : Fetch latest Zulu Java builds. ---------------------------------- 54.52s
170-
docker.docker-jenkins: temurin : Fetch latest Temurin Java builds. ---------------------------- 46.20s
171-
docker.docker-jenkins: zulu : Unpack Zulu Java Installations. --------------------------------- 35.03s
172-
docker.docker-jenkins: libnetcdf-and-deps : Install netCDF-c. --------------------------------- 28.84s
173-
docker.docker-jenkins: general-packages : Install os managed tools. --------------------------- 28.32s
174-
docker.docker-jenkins: temurin : Unpack Temurin Java Installations. --------------------------- 26.71s
175-
docker.docker-jenkins: general-packages : Install os managed tools. --------------------------- 24.31s
176-
docker.docker-jenkins: geerlingguy.ruby : Install ruby and other required dependencies. ------- 12.96s
177-
docker.docker-jenkins: general-packages : Install os managed tools. --------------------------- 12.77s
178-
docker.docker-jenkins: miniconda : Download and unpack miniconda. ------------------------------ 9.31s
179-
docker.docker-jenkins: libnetcdf-and-deps : Install zlib. -------------------------------------- 5.46s
180-
docker.docker-jenkins: libnetcdf-and-deps : Configure zlib. ------------------------------------ 4.13s
181-
docker.docker-jenkins: security : Update SSH configuration to be more secure. ------------------ 3.78s
182-
docker.docker-jenkins: libnetcdf-and-deps : Download and unpack hdf5. -------------------------- 3.59s
183-
docker.docker-jenkins: zulu : Read versions of installed Zulu. --------------------------------- 3.34s
184-
docker.docker-jenkins: cleanup : Remove packages that are not needed in final environment. ----- 3.07s
160+
docker.docker-jenkins: Wait for the HDF5 async test task to complete. ------------------------ 362.87s
161+
docker.docker-jenkins: libnetcdf-and-deps : Install hdf5. ------------------------------------ 328.13s
162+
docker.docker-jenkins: libnetcdf-and-deps : Configure netCDF-c. ------------------------------ 180.21s
163+
docker.docker-jenkins: libnetcdf-and-deps : Configure hdf5. ---------------------------------- 135.15s
164+
docker.docker-jenkins: temurin : Fetch latest Temurin Java builds. ---------------------------- 83.71s
165+
docker.docker-jenkins: zulu : Fetch latest Zulu Java builds. ---------------------------------- 77.12s
166+
docker.docker-jenkins: general-packages : Install os managed tools. --------------------------- 41.00s
167+
docker.docker-jenkins: corretto : Fetch latest Corretto Java builds. -------------------------- 40.41s
168+
docker.docker-jenkins: zulu : Unpack Zulu Java Installations. --------------------------------- 37.98s
169+
docker.docker-jenkins: general-packages : Install os managed tools. --------------------------- 36.87s
170+
docker.docker-jenkins: libnetcdf-and-deps : Install netCDF-c. --------------------------------- 34.90s
171+
docker.docker-jenkins: corretto : Unpack Corretto Java Installations. ------------------------- 28.92s
172+
docker.docker-jenkins: temurin : Unpack Temurin Java Installations. --------------------------- 28.57s
173+
docker.docker-jenkins: general-packages : Install os managed tools. --------------------------- 15.22s
174+
docker.docker-jenkins: libnetcdf-and-deps : Install zlib. -------------------------------------- 6.27s
175+
docker.docker-jenkins: security : Update SSH configuration to be more secure. ------------------ 5.02s
176+
docker.docker-jenkins: libnetcdf-and-deps : Configure zlib. ------------------------------------ 4.52s
177+
docker.docker-jenkins: zulu : Read versions of installed Zulu. --------------------------------- 3.74s
178+
docker.docker-jenkins: libnetcdf-and-deps : Download and unpack hdf5. -------------------------- 3.65s
179+
docker.docker-jenkins: cleanup : Remove packages that are not needed in final environment. ----- 3.54s
185180
~~~

packer/provisioners/ansible/group_vars/all.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
install_dir: /usr/thredds-test-environment
44
tmp_dir: /tmp/thredds-ansible-tmp
55

6-
# Shared between gradle-builds-cache-bootstrap and cleanup roles.
7-
tmp_repo_dir: "{{ tmp_dir }}/git_repositories"
8-
gradle_user_home: "/home/{{ thredds_test_user }}/.gradle"
9-
106
# The variable thredds_test_user is defined in the packer configuration
117
# located at packer/thredds-test-env.json.
128

@@ -29,18 +25,3 @@ hdf5_async_check_retries: 80
2925
netcdf_c_async_timeout: 1800 # seconds (30 minutes)
3026
netcdf_c_async_check_interval: 120 # seconds
3127
netcdf_c_async_check_retries: 30
32-
33-
miniconda_async_timeout: 1800 # seconds (30 minutes)
34-
miniconda_async_check_interval: 60 # seconds
35-
miniconda_async_check_retries: 30
36-
37-
git_clone_async_timeout: 600 # seconds (10 minutes)
38-
git_clone_async_check_interval: 20 # seconds
39-
git_clone_async_check_retries: 30
40-
41-
bootstrap_gradle_cache_async_timeout: 1800 # seconds (30 minutes)
42-
bootstrap_gradle_cache_async_check_interval: 60 # seconds
43-
bootstrap_gradle_cache_async_check_retries: 30
44-
45-
# geerlingguy.ruby role variables
46-
ruby_install_bundler: false

packer/provisioners/ansible/requirements.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

packer/provisioners/ansible/roles/cleanup/tasks/main.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
11
---
2-
- name: "Cleanup temporary git repository directory."
3-
file:
4-
path: "{{ tmp_repo_dir }}"
5-
state: absent
6-
7-
- name: Check if gradle cache directory exists.
8-
stat:
9-
path: "{{ gradle_user_home }}"
10-
register: gradle_user_home_check
11-
12-
- name: "Change owner of gradle cache directory to be {{ thredds_test_user }}."
13-
when: gradle_user_home_check.stat.exists == true
14-
file:
15-
path: "{{ gradle_user_home }}"
16-
owner: "{{ thredds_test_user }}"
17-
recurse: yes
18-
192
- name: Prepare to add thredds-test-environment native libraries to run-time linker
203
copy:
214
dest: "/etc/ld.so.conf.d/tte.conf"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: Fetch latest Corretto Java builds.
3+
uri:
4+
url: "https://corretto.aws/downloads/latest/amazon-corretto-{{ item }}-x64-linux-jdk.tar.gz"
5+
method: GET
6+
follow_redirects: safe
7+
dest: "/tmp/{{ base_install_name }}{{ item }}.tar.gz"
8+
# Expect 200 locally (i.e. Docker builder), 304 (for some versions) on AWS EC2.
9+
status_code: [200, 304]
10+
register: uri_result
11+
retries: "{{ network_call_retries }}"
12+
delay: "{{ network_call_time_between_retries }}"
13+
until: ("status" in uri_result) and (uri_result.status == 200 or uri_result.status == 304)
14+
loop: "{{ java_versions }}"
15+
16+
- debug:
17+
var: uri_result
18+
verbosity: 2
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
- name: Create installation directories, if they do not exist.
3+
file:
4+
path: "{{ install_dir }}/{{ base_install_name }}{{ item }}"
5+
state: directory
6+
loop: "{{ java_versions }}"
7+
loop_control:
8+
label: "Create Directory for Corretto {{ item }} Installation"
9+
10+
- import_tasks: fetch_remote.yml
11+
tags: [ fetch-remote ]
12+
13+
- name: Unpack Corretto Java Installations.
14+
unarchive:
15+
src: "/tmp/{{ base_install_name }}{{ item }}.tar.gz"
16+
dest: "{{ install_dir }}/{{ base_install_name }}{{ item }}"
17+
extra_opts: [--strip-components=1]
18+
creates: "{{ install_dir }}/{{ base_install_name }}{{ item }}/bin"
19+
remote_src: yes
20+
loop: "{{ java_versions }}"
21+
loop_control:
22+
label: "Unpack Corretto {{ item }}"
23+
24+
- name: Read versions of installed Corretto.
25+
shell: "{{ install_dir }}/{{ base_install_name }}{{ item }}/bin/java -version"
26+
register: shell_output
27+
loop: "{{ java_versions }}"
28+
loop_control:
29+
label: "Read Corretto {{ item }} Version Information"
30+
31+
- name: Print versions of installed Corretto Java instances.
32+
debug:
33+
msg="{{ item.stderr_lines[1] }}"
34+
loop: "{{ shell_output.results }}"
35+
loop_control:
36+
label: "Corretto {{ item.item }} Version:"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
base_install_name: corretto
3+
4+
java_versions:
5+
- 8
6+
- 11
7+
- 17
8+
- 21

packer/provisioners/ansible/roles/gradle-builds-cache-bootstrap/tasks/bootstrap-cache-repo-branch.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

packer/provisioners/ansible/roles/gradle-builds-cache-bootstrap/tasks/clone-repo-branch.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

packer/provisioners/ansible/roles/gradle-builds-cache-bootstrap/tasks/main.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)