Skip to content

Commit

Permalink
Refactor/update (#1)
Browse files Browse the repository at this point in the history
* Update 3M Editor
* Update Dockerfile build
* Improve compatibility with Docker
  * port mapping
  * bind mounts
  * volumes
* Add Docker Compose configurations
  • Loading branch information
fkraeutli authored Feb 13, 2024
1 parent 27cc9e8 commit ee1dc04
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 30 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PORT_EDITOR=8080
PORT_DB=8081

# Use volumes
COMPOSE_FILE=./docker-compose.yml:./docker-compose.volumes.yml

# Use bind mounts
#COMPOSE_FILE=./docker-compose.yml:./docker-compose.binds.yml
20 changes: 2 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
Resources/3M/BackUp/*
!Resources/3M/BackUp/.gitkeep
Resources/3M/export_import/*
!Resources/3M/export_import/.gitkeep
Resources/3M/rdf_visualizer_files/*
!Resources/3M/rdf_visualizer_files/.gitkeep
Resources/3M/uploads/Mapping/example_files/*
!Resources/3M/uploads/Mapping/example_files/.gitkeep
Resources/3M/uploads/Mapping/generator_files/*
!Resources/3M/uploads/Mapping/generator_files/.gitkeep
Resources/3M/uploads/Mapping/Other/*
!Resources/3M/uploads/Mapping/Other/.gitkeep
Resources/3M/uploads/Mapping/rdf_schema/*
!Resources/3M/uploads/Mapping/rdf_schema/.gitkeep
Resources/3M/uploads/Mapping/uploadsTemp/*
!Resources/3M/uploads/Mapping/uploadsTemp/.gitkeep
Resources/3M/uploads/Mapping/xml_schema/*
!Resources/3M/uploads/Mapping/xml_schema/.gitkeep
binds/*
.env
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ ADD Resources/SW/apache-tomcat-8.0.53.tar.gz /opt/
ADD Resources/WARs/*.tar.gz /opt/apache-tomcat-8.0.53/webapps/
ADD x3mlMapper /opt/apache-tomcat-8.0.53/webapps/x3mlMapper

VOLUME ["/opt/exist/webapp/WEB-INF/data/","/opt/apache-tomcat-8.0.53/", "/opt/3M/"]

ADD entrypoint.sh /entrypoint.sh
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf

RUN chmod +x ./entrypoint.sh

VOLUME ["/opt/exist/webapp/WEB-INF/data/", "/opt/3M"]

EXPOSE 8080 8081

ENTRYPOINT ["/entrypoint.sh"]
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,33 @@ Apart from Java 3M requires the following:

The image creates a running instance of Apache Tomcat, with the required 3M webapps and resources allready shipped in, so that it can work as the underlying layer of 3M framework. The container starts tomcat container and listens for incoming connection at port 8080. The following environment variables are available for managing the apache tomcat container:

* IP_ADDRESS: allows the user defining the IP address (the external one) where docker is running. This will allow configuring 3M web applications with the proper external IP address they are available into. If the variable is not set when running the container, then the default IP address will be used (localhost)

To start your container using port 8080 (for 3M webapps) and 8081 (for eXistdb) using the external IP address 123.123.123.123:
To start your container using port 8080 (for 3M webapps) and 8081 (for eXistdb):

```
docker run -d -p 8080:8080 -p 8081:8081 -e IP_ADDRESS=123.123.123.123 marketak/3m-docker:latest
docker run -d -p 8080:8080 -p 8081:8081 swissartresearx/3m-docker:latest
```

After running the container you can check if the instance is up and running by pasting the links below in your web browser

```
http://123.123.123.123:8080/3M
http://123.123.123.123:8081/exist
http://localhost:8080/3M
http://localhost:8081/exist
```

For maintability reasons, 3M docker image exposes the following volumes which are mounted in the filesystem where the container is running (for more infromation about the actual location of these volumes in the target filesystem use docker inspect command)
* data from eXist-DB
* tomcat folder
* 3M shared resources

### Docker Compose

The repository contains a docker-compose file that can be used to start the 3M container. To use the configuration, first create an `.env` file based on the example file `.env.example`, edit as required, and then run the following command:

```
docker-compose up -d
```
To use bind mounts uncomment the respective `COMPOSE_FILE` line in the `.env` file and create and initialise the required directories by running the `createFoldersForBindMounts.sh` script.

### Maintainers

Yannis Marketakis (marketak 'at' ics 'dot' forth 'dot' gr)
Florian Kräutli (florian.kraeutli 'at' uzh 'dot' ch)
Binary file modified Resources/WARs/3MEditor.tar.gz
Binary file not shown.
3 changes: 3 additions & 0 deletions createFoldersForBindMounts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mkdir -p binds/exist
mkdir -p binds/3M
tar -xzf Resources/data.tar.gz -C binds/exist
13 changes: 13 additions & 0 deletions docker-compose.binds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

version: "3"
services:
editor:
build: .
container_name: 3m-docker
image: swissartresearx/3m-docker:latest
ports:
- 8080:8080
- 8081:8081
volumes:
- ./binds/exist/data:/opt/exist/webapp/WEB-INF/data/
- ./binds/3M:/opt/3M
6 changes: 6 additions & 0 deletions docker-compose.volumes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: "3"
services:
editor:
volumes:
- db-data:/opt/exist/webapp/WEB-INF/data/
- editor-data:/opt/3M
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: "3"
services:
editor:
build: .
container_name: 3m-docker
image: swissartresearx/3m-docker:latest
ports:
- ${PORT_EDITOR}:8080
- ${PORT_DB}:8081
volumes:
db-data:
editor-data:
5 changes: 2 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
if [ -z "$IP_ADDRESS" ]; then
echo "The parameter for setting the public IP is missing (IP_ADDRESS)"
echo "Setting the IP to localhost"
IP_ADDRESS="localhost"
else
IP_ADDRESS="0.0.0.0"
fi
# inject ip address
echo "injecting the IP adrress $IP_ADDRESS"
sed -i s/255.255.255.255/$IP_ADDRESS/g $CATALINA_HOME/webapps/3M/WEB-INF/web.xml
Expand All @@ -17,6 +17,5 @@ sed -i s/255.255.255.255/$IP_ADDRESS/g $CATALINA_HOME/webapps/Maze/singlemapping
sed -i s/255.255.255.255/$IP_ADDRESS/g $CATALINA_HOME/webapps/Maze/WEB-INF/config.properties
sed -i s/255.255.255.255/$IP_ADDRESS/g $CATALINA_HOME/webapps/Maze/app/js/Controller.js

fi
# start eXist-db and Apache Tomcat
exec supervisord -n

0 comments on commit ee1dc04

Please sign in to comment.