Skip to content

Commit

Permalink
eclipse-rdf4jGH-5064: added docker makefile for Jetty 9 and updated e…
Browse files Browse the repository at this point in the history
…2e tests
  • Loading branch information
barthanssens committed Jul 22, 2024
1 parent 51f044a commit 7e70a2e
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 25 deletions.
35 changes: 35 additions & 0 deletions docker/Dockerfile-jetty
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Temp to reduce image size
FROM ubuntu:jammy AS temp

RUN apt-get clean && apt-get update && apt-get install -y unzip


COPY ignore/rdf4j.zip /tmp/rdf4j.zip

WORKDIR /tmp

RUN unzip -q /tmp/rdf4j.zip

# Final workbench
FROM jetty:9.4-jre17-eclipse-temurin
LABEL org.opencontainers.image.authors="Bart Hanssens (bart.hanssens@bosa.fgov.be)"

USER root

RUN apt-get update && apt-get -y install dumb-init && apt-get clean

ENV JAVA_OPTS="-Xmx2g -Dorg.eclipse.rdf4j.appdata.basedir=/var/rdf4j -Dorg.eclipse.rdf4j.rio.jsonld_secure_mode=false -Dorg.eclipse.jetty.annotations.AnnotationParser.LEVEL=OFF"

COPY --from=temp /tmp/eclipse-rdf4j*/war/*.war /var/lib/jetty/webapps/

RUN mkdir -p /var/rdf4j && \
chown -R jetty:jetty /var/rdf4j /var/lib/jetty/webapps && \
java -jar $JETTY_HOME/start.jar --add-to-start=logging-jetty

USER jetty

ENTRYPOINT ["dumb-init", "--"]
CMD ["java", "-jar", "/usr/local/jetty/start.jar"]

EXPOSE 8080

File renamed without changes.
11 changes: 6 additions & 5 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ cp "$ZIP" "${CURRENT}/ignore/rdf4j.zip"
cd "$CURRENT"

# build
echo "Building docker image"
docker compose build --pull --no-cache
APP_SERVER=${APP_SERVER:-tomcat}
echo "Building docker image for ${APP_SERVER}"

docker tag docker-rdf4j:latest eclipse/rdf4j-workbench:${MVN_VERSION}
docker compose build --pull --no-cache
docker tag docker-rdf4j:latest eclipse/rdf4j-workbench-${APP_SERVER}:${MVN_VERSION}

echo "
Docker image tagged as:
docker-rdf4j:latest
eclipse/rdf4j-workbench:${MVN_VERSION}
docker-rdf4j:latest
eclipse/rdf4j-workbench-${APP_SERVER}:${MVN_VERSION}
To start the workbench and server:
docker compose up -d
Expand Down
9 changes: 6 additions & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ services:
rdf4j:
environment:
- APP_LOGGING_LEVEL=${APP_LOGGING_LEVEL}
- APP_SERVER=${APP_SERVER:-tomcat}
ports:
- 127.0.0.1:8080:8080
build: .
build:
context: .
dockerfile: Dockerfile-${APP_SERVER:-tomcat}
restart: always
volumes:
- rdf4j_data:/var/rdf4j
- rdf4j_logs:/usr/local/tomcat/logs
- rdf4j_logs:/usr/local/${APP_SERVER:-tomcat}/logs

volumes:
rdf4j_data:
rdf4j_logs:
rdf4j_logs:
4 changes: 2 additions & 2 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
set -e
./build.sh

echo "Starting the docker container"
echo "Starting the docker container for ${APP_SERVER}"
docker compose up --force-recreate -d

# Wait for the server to be ready. Server is ready when the log contains something like "org.apache.catalina.startup.Catalina.start Server startup in 3400 ms".
printf '%s' "Waiting for container to be ready"
while ! docker compose logs rdf4j | grep -q "Server startup in"; do
while ! docker compose logs rdf4j | grep -q -e "Server startup in" -e "Started ServerConnector"; do
printf '%s' "."
# Exit with error if we have looped 30 times (e.g. 30 seconds)
((c++)) && ((c == 30)) && echo "" && docker compose logs | tee && echo "" && docker ps -a | tee && printf '\n%s\n' "Timed out while waiting!" >&2 && exit 1
Expand Down
6 changes: 6 additions & 0 deletions docker/shutdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -e

echo "Stopping the docker container for ${APP_SERVER}"
docker compose down --rmi all -v

38 changes: 23 additions & 15 deletions e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,31 @@

set -e

cd ..
cd docker
./run.sh
./waitForDocker.sh
cd ..
cd e2e
for APP_SERVER in tomcat jetty; do
export APP_SERVER

cd ..
cd docker
./run.sh
./waitForDocker.sh
cd ..
cd e2e

sleep 10
sleep 10

if [ ! -d 'node_modules' ]; then
echo "npm ci"
npm ci
fi
if [ ! -d 'node_modules' ]; then
echo "npm ci"
npm ci
fi

docker ps
docker ps

npx playwright install --with-deps # install browsers
npx playwright test
exit $?
npx playwright install --with-deps # install browsers
npx playwright test

cd ..
cd docker
./shutdown.sh
done

exit $?

0 comments on commit 7e70a2e

Please sign in to comment.