Skip to content

Commit

Permalink
#157 Update Dockerfile and GradleDockerFile to use JDK 11 (#158)
Browse files Browse the repository at this point in the history
* Update GradleDockerfile

* Bump to OpenJDK11

* Updated Dockerfile

* Update Commander utils to use OpenJDK 11.

* #157: Updated GradleDockerfile to run current ./gradlew with OpenJDK11

* #157: Parameterized GradleDockerfile

* #157: Removed unnecessary build command

* #157: Updated .dockerignore

* #157: Switched to different OpenJDK source (old one deprecated) and tidied up build

* #157: Updated README

---------

Co-authored-by: darnjo <josh@reso.org>
  • Loading branch information
darnjo and darnjo committed Sep 4, 2023
1 parent 0eaecc2 commit 64af49d
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 120 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
out/
.github
.git
.DS_Store
.idea
.run
odata-openapi/
15 changes: 0 additions & 15 deletions CommanderTestingContainer

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gradle:8.0.2-jdk8 AS builder
FROM gradle:8.0.2-jdk11 AS builder

WORKDIR /home/gradle/project

Expand All @@ -10,7 +10,7 @@ RUN ls

FROM alpine:latest

RUN apk add --update bash ca-certificates openjdk8-jre-base nss git && \
RUN apk add --update bash ca-certificates openjdk11 nss git && \
rm -rf /var/cache/apk/*

COPY --from=builder /home/gradle/project/build/libs/web-api-commander.jar ./
Expand Down
23 changes: 15 additions & 8 deletions GradleDockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
FROM alpine:3.17.2
FROM sapmachine:jdk-headless-ubuntu-11

RUN apk add --update bash ca-certificates openjdk8-jre-base nss git gradle && \
rm -rf /var/cache/apk/*
ARG WORKING_PATH=/home/gradle
ARG BUILD_DIR=${WORKING_PATH}/build
ARG CERTIFICATION_RESULTS_PATH=${BUILD_DIR}/certification
ARG GRADLE_CACHE=${WORKING_PATH}/.gradle

RUN git clone --single-branch --branch main https://github.com/RESOStandards/web-api-commander.git
WORKDIR ${WORKING_PATH}

WORKDIR web-api-commander
ADD ./ ./

RUN gradle jar
ENV GRADLE_USER_HOME=${GRADLE_CACHE}

ENTRYPOINT ["gradle"]
CMD ["tasks"]
RUN ./gradlew --no-daemon clean jar

RUN mkdir -p ${CERTIFICATION_RESULTS_PATH}
RUN ln -s ${CERTIFICATION_RESULTS_PATH} /

ENTRYPOINT ["./gradlew", "--no-daemon", "--quiet"]
CMD ["tasks"]
9 changes: 3 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ String pathToMetadata = null,
pathToRESOScript = null,
certFileName = null

final String certOutputDir = 'build' + File.separator + 'certification',
final String buildDir = 'build',
certOutputDir = buildDir + File.separator + 'certification',
cucumberJsonPath = certOutputDir + File.separator + 'cucumberJson',
certReportsDir = certOutputDir + File.separator + 'reports',
certResultsDir = certOutputDir + File.separator + 'results'
Expand All @@ -93,7 +94,7 @@ tasks.register('prepareCertificationEnvironment') {
doLast {
def folder = new File(certOutputDir)
if (folder.exists()) {
delete certOutputDir
delete(fileTree(certOutputDir))
}

mkdir certOutputDir
Expand Down Expand Up @@ -288,10 +289,6 @@ tasks.register('testDataDictionaryReferenceMetadata_1_7') {
'org.reso.certification.stepdefs#DataDictionary',
'src/main/java/org/reso/certification/features/data-dictionary/v1-7-0'
]

if (System.hasProperty("pretty")) {
args.add("--plugin", "pretty")
}
}
}
}
Expand Down
63 changes: 45 additions & 18 deletions doc/Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,69 @@ RESO automated testing tools and Commander utilities can both be run in a Docker
The containers are slightly different in each case.

### RESO Automated Testing Tools
A [GradleDockerfile](../GradleDockerfile) has been provided in order to prepare a Gradle
environment for the Commander. The container builds itself from the main branch of the source code, so you don't need
the entire repo checked out locally, just the file.
A separate file called [GradleDockerfile](../GradleDockerfile) has been provided in order to prepare a Gradle environment for the Commander. This can also be used in CI/CD environments such as Jenkins or TravisCI.

This can also be used in CI/CD environments such as Jenkins or TravisCI.
#### Building the Docker Container

Run the RESO Certification tests in a Docker container locally by issuing one of the following commands.
Docker must be running on your local machine.
In order to build the Docker container for yourself, download the source code with:

One way to do this is to build the container first and then run it:
```git clone https://github.com/RESOStandards/web-api-commander.git```

```docker build --file GradleDockerfile -t web-api-commander-gradle .```
You can [download Docker here](https://www.docker.com/) or [here](https://www.docker.com/products/docker-desktop/) if you prefer the desktop version. Make sure it's running before proceeding.

Once the container is built, you can use the Gradle commands normally with:
```docker run -it web-api-commander-gradle testWebApiCore_2_0_0 -DpathToRESOScript=/home/gradle/project/resoscripts/your.resoscript -DshowResponses=true```
To check, you can use:

You can also build the container on the fly:
```docker --version```

```docker run --rm -it -v "$PWD":/home/gradle/project -v /path/to/your/resoscripts:/home/gradle/project/resoscripts -w /home/gradle/project -it $(docker build -f GradleDockerfile -q .) testWebApiCore_2_0_0 -DpathToRESOScript=/home/gradle/project/resoscripts/your.resoscript -DshowResponses=true```
At this point, you can build the container:

```docker build --file GradleDockerfile -t web-api-commander-gradle --no-cache .```

This will create a Docker container caled `web-api-commander-gradle`, which you should be able to see if you type `docker images`:

```
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
web-api-commander-gradle latest 341991b8d352 About a minute ago 1.06GB
...
```

#### Available Tasks

To see available tasks, issue the following command at the terminal:

```
$ docker run -it web-api-commander-gradle
```

#### Running Data Dictionary 1.7 Tests
Now that the Docker container is working, you can run the Data Dictionary tests.

First you'll need to create the following:
* An empty directory so the certification results may be viewed
* A configuration (RESOScript) file that you can mount in the Docker container

For example:

```
$ docker run -it -v /path/to/test.resoscript:/test.resoscript -v /path/to/commander-build-tmp:/certification web-api-commander-gradle testDataDictionary_1_7 -DpathToRESOScript=/test.resoscript
```

In the example, replace `/path/to/test.resoscript` and `/path/to/commander-build-tmp` with your local paths. You can then pass the `pathToRESOScript` arg to the commander, as shown above.

Note that this will create a directory in your home directory for the project, and build artifacts and the log will be placed in that directory,
which is also where you will end up after runtime.

You may need to adjust the path separators if using Windows.


### Commander Utilities
A [Dockerfile](../Dockerfile) has also been provided to Dockerize the application for Commander utilities.
### Commander JAR and Utilities
A [Dockerfile](../Dockerfile) has also been provided to Dockerize the application for the Commander utilities accessible through the JAR file.

To run the Commander utilities, use the following commands:

```
$ docker build -t web-api-commander .
```

The usage for the docker container is the same for `web-api-commander.jar` presented above.
Once the container is built, you can see available tasks using the following command:

```
$ docker run -it web-api-commander --help
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
org.gradle.jvmargs=-Xmx28g
org.gradle.warning.mode=all
org.gradle.caching=true
71 changes: 0 additions & 71 deletions runCommander.sh

This file was deleted.

0 comments on commit 64af49d

Please sign in to comment.