Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Release docker image

on:
Expand All @@ -19,14 +18,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn --batch-mode --update-snapshots package
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
Expand Down
30 changes: 19 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
### Build and Compilation ###
/target/
.settings
/bin/

### Editor ###
.settings/
.settings/org.eclipse.core.resources.prefs
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.m2e.core.prefs
/.project
/.classpath
.pydevproject
*.iml
*.log
**/site/sphinx/build/*
.idea
.vscode/
*.swp
*.swo
*~

### Eclipse ###
.settings/org.eclipse.core.resources.prefs
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.m2e.core.prefs
### Logs ###
*.log
spring-shell.log

### Docker ###
docker-compose-local*
### Documentation ###
**/site/sphinx/build/*

### Spring ###
spring-shell.log
### Docker ###
*compose*.yml
!compose.yml
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
FROM eclipse-temurin:17-jre
# syntax=docker/dockerfile:1

# deployment unit
COPY target/ChannelFinder-*.jar /channelfinder/ChannelFinder-*.jar
FROM eclipse-temurin:17-jdk AS builder
WORKDIR /build
RUN apt-get update && apt-get install -y maven
COPY . .
RUN mvn --batch-mode --update-snapshots clean package -DskipTests

CMD ["java", "-jar", "/channelfinder/ChannelFinder-*.jar", "--spring.config.name=application"]
FROM eclipse-temurin:17-jre AS runner
WORKDIR /app
COPY --from=builder /build/target/ChannelFinder-*.jar ./channelfinder.jar
CMD ["java", "-jar", "/app/channelfinder.jar", "--spring.config.name=application"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ChannelFinder is a Java EE5 REST-style web service. The directory data is held i

### Docker Compose

For using docker containers there is a barebones [docker compose file](./docker-compose.yml).
For using docker containers there is a barebones [docker compose file](./compose.yml).

### Manual Installation

Expand Down
22 changes: 10 additions & 12 deletions docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
channelfinder:
build: .
Expand All @@ -8,21 +7,15 @@ services:
- channelfinder-net
ports:
- "8443:8443"
depends_on:
- elasticsearch
environment:
- ELASTICSEARCH_NETWORK_HOST=elasticsearch-cf
command: >
/bin/bash -c "
until curl --silent --fail http://elasticsearch-cf:9200/_cluster/health; do
echo 'Waiting for Elasticsearch'
sleep 1
done
java -jar /channelfinder/ChannelFinder-*.jar"
- ELASTICSEARCH_NETWORK_HOST=elasticsearch
depends_on:
elasticsearch:
condition: service_healthy

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.2
hostname: elasticsearch-cf
hostname: elasticsearch
networks:
- channelfinder-net
ports:
Expand All @@ -35,6 +28,11 @@ services:
EPICS_PVAS_INTF_ADDR_LIST: "0.0.0.0"
volumes:
- channelfinder-es-data:/usr/share/elasticsearch/data
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health"]
interval: 10s
timeout: 5s
retries: 3
volumes:
channelfinder-es-data:
driver: local
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
/**
* Integration tests for ChannelFinder and Elasticsearch with focus on usage of
* {@link org.phoebus.channelfinder.CFResourceDescriptors#CHANNEL_RESOURCE_URI}.
* Existing dockerization is used with <tt>docker-compose-integrationtest.yml</tt> and <tt>Dockerfile.integrationtest</tt>.
*
* @author Lars Johansson
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

/**
* Integration tests for ChannelFinder and Elasticsearch with focus on endpoints being available.
* Existing dockerization is used with <tt>docker-compose-integrationtest.yml</tt> and <tt>Dockerfile.integrationtest</tt>.
*
* @author Lars Johansson
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
/**
* Integration tests for ChannelFinder and Elasticsearch with focus on usage of
* {@link org.phoebus.channelfinder.CFResourceDescriptors#PROPERTY_RESOURCE_URI}.
* Existing dockerization is used with <tt>docker-compose-integrationtest.yml</tt> and <tt>Dockerfile.integrationtest</tt>.
*
* @author Lars Johansson
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
/**
* Integration tests for ChannelFinder and Elasticsearch with focus on usage of
* {@link org.phoebus.channelfinder.CFResourceDescriptors#SCROLL_RESOURCE_URI}.
* Existing dockerization is used with <tt>docker-compose-integrationtest.yml</tt> and <tt>Dockerfile.integrationtest</tt>.
*
* @author Lars Johansson
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
/**
* Integration tests for ChannelFinder and Elasticsearch with focus on usage of
* {@link org.phoebus.channelfinder.CFResourceDescriptors#TAG_RESOURCE_URI}.
* Existing dockerization is used with <tt>docker-compose-integrationtest.yml</tt> and <tt>Dockerfile.integrationtest</tt>.
*
* @author Lars Johansson
*
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/phoebus/channelfinder/docker/ITUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class ITUtil {
public static final ObjectMapper MAPPER = new ObjectMapper();

public static final String CHANNELFINDER = "channelfinder";
public static final String INTEGRATIONTEST_DOCKER_COMPOSE = "docker-compose-integrationtest.yml";
public static final String INTEGRATIONTEST_DOCKER_COMPOSE = "src/test/resources/compose.yml";

// code coverage

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.integrationtest → src/test/resources/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
FROM eclipse-temurin:17-jre

# deployment unit
COPY target/ChannelFinder-*.jar /channelfinder/ChannelFinder-*.jar
COPY ../../../target/ChannelFinder-*.jar /channelfinder/ChannelFinder-*.jar

# code coverage
COPY target/jacoco/jacocoagent.jar /channelfinder/jacocoagent.jar
COPY ../../../target/jacoco/jacocoagent.jar /channelfinder/jacocoagent.jar

CMD ["java", "-jar", "/channelfinder/ChannelFinder-*.jar", "--spring.config.name=application"]
4 changes: 2 additions & 2 deletions src/test/resources/INTEGRATIONTEST_DOCKER_RUN.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ mvn clean install test-compile failsafe:integration-test failsafe:verify --batch
##### Build

* (Re) Build after change in `src/main/java` in order for change to be tested
* `Dockerfile.integrationtest` relies on built code and not on Maven central
* `Dockerfile` relies on built code and not on Maven central
* Requires a deployable jar

##### Configuration

* Configuration in folder `src/test/java` and package `org.phoebus.channelfinder.docker`, e.g. urls and port numbers, is coupled to files `Dockerfile.integrationtest` and `docker-compose-integrationtest.yml` (beside `src/main/resources/application.properties`)
* Configuration in folder `src/test/java` and package `org.phoebus.channelfinder.docker`, e.g. urls and port numbers, is coupled to files `src/test/resources/Dockerfile` and `src/test/resources/compose.yml` (beside `src/main/resources/application.properties`)

##### Debug

Expand Down
10 changes: 5 additions & 5 deletions src/test/resources/INTEGRATIONTEST_DOCKER_TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ It is possible to test ChannelFinder API by running ChannelFinder and Elasticsea
##### Files

* folder `src/test/java` and package `org.phoebus.channelfinder.docker`
* [docker-compose-integrationtest.yml](docker-compose-integrationtest.yml)
* [Dockerfile.integrationtest](Dockerfile.integrationtest)
* [compose.yml](src/test/resources/compose.yml)
* [Dockerfile](src/test/resources/Dockerfile)

### Examples

Expand Down Expand Up @@ -87,7 +87,7 @@ How

### How it works - big picture

Integration tests are implemented in test class annotated with `@Testcontainers`. Test class starts a docker container for the application (ChannelFinder service) and another docker container for elastic (Elasticsearch) through `docker-compose-integrationtest.yml` and `Dockerfile.integrationtest` after which JUnit tests are run.
Integration tests are implemented in test class annotated with `@Testcontainers`. Test class starts a docker container for the application (ChannelFinder service) and another docker container for elastic (Elasticsearch) through `src/test/resources/compose.yml` and `src/test/resources/Dockerfile` after which JUnit tests are run.

```
@Testcontainers
Expand Down Expand Up @@ -320,8 +320,8 @@ public class ChannelFinderChannelsIT {

##### Note

* (Re) Build after change in `src/main/java` is needed in order for change to be tested as `Dockerfile.integrationtest` relies on built code.
* Configuration in folder `src/test/java` and package `org.phoebus.channelfinder.docker`, e.g. urls and port numbers, is coupled to files `Dockerfile.integrationtest` and `docker-compose-integrationtest.yml` (beside `src/main/resources/application.properties`).
* (Re) Build after change in `src/main/java` is needed in order for change to be tested as `Dockerfile` relies on built code.
* Configuration in folder `src/test/java` and package `org.phoebus.channelfinder.docker`, e.g. urls and port numbers, is coupled to files `src/test/resources/Dockerfile` and `src/test/resources/compose.yml` (beside `src/main/resources/application.properties`).
* Both positive and negative tests are important to ensure validation works as expected.

### How to run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# ------------------------------------------------------------------------------

version: "3.7"
services:
channelfinder:
build:
context: .
dockerfile: Dockerfile.integrationtest
build:
context: ../../..
dockerfile: src/test/resources/Dockerfile
hostname: channelfinder
networks:
- channelfinder-net
Expand Down
Loading