OpenAS2 / OpenAs2App

OpenAS2 is a java-based implementation of the EDIINT AS2 standard. It is intended to be used as a server. It is extremely configurable and supports a wide variety of signing and encryption algorithms.
https://sourceforge.net/projects/openas2/
BSD 2-Clause "Simplified" License
177 stars 132 forks source link

v3.7.0 overwrites partnerships.xml on recreation of container #346

Closed sonykphilip closed 1 month ago

sonykphilip commented 8 months ago

Hi Team, I am running OpenAS2 v3.7.0 using the provided docker-compose.yaml.

The partnerships.xml is a volume mount in the docker-compose.yaml:

volumes:
  - /opt/openas2/config/openas2.properties:/opt/openas2/config/openas2.properties
  - /opt/openas2/config/partnerships.xml:/opt/openas2/config/partnerships.xml

In the /opt/openas2/config/openas2.properties: partnership_file=/opt/openas2/config/partnerships.xml

On changing any values in the compose file and running 'docker compose up -d', the openas2-server container gets recreated and the partnerships.xml file is overwritten with the defaults.

'docker compose restart' does not have any issues.

Could this be related to Webui fix not persisting changes to partnerships #332 ?

Thank you in advance for the help.

uhurusurfa commented 8 months ago

I think you are using someones fork of the official OpenAS2 code base because the sample docker-compose.yml for this repo does not specify any volumes: https://github.com/OpenAS2/OpenAs2App/blob/master/docker-compose.yml

sonykphilip commented 8 months ago

I'm sorry that I wasn't clear enough. I modified the provided compose file from the repo and added the volumes.

But the question was about why the partnerships file would get overwritten on a recreate, IAC.

uhurusurfa commented 8 months ago

When you say it gets overwritten with the defaults, what defaults are these and where is the file containing the defaults stored? The code has no concept of a default set of partnerships so the only possibility I can think of is that there must be a second file somewhere that contains the defaults and somehow docker is copying it into the volume.

sonykphilip commented 8 months ago

The contents of this file is what I see after it recreates the container https://github.com/OpenAS2/OpenAs2App/blob/master/Server/src/config/partnerships.xml

This seems to be happening during the server startup process. Docker is not doing anything here other than mapping the hostfs file inside the container to that specific location.

What I have done now is to copy all the files+dirs from the 'openas2/config' dir inside the container onto the hostfs and changed the the line to:

volumes:
  - /opt/openas2/config:/opt/openas2/config

This seems to work.

I wanted to only change the files which I really needed to change and leave the rest as is. But now I have the contents of the whole config directory on the hostfs.

This is my current openas2-server section in the compose file

services:
  openas2:
    container_name: openas2
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 4080:10080
      - 4099:10099
      - 4081:10081
      - 4443:10443
      - 4444:10444
    environment:
      - OPENAS2_PROPERTIES_FILE=/opt/openas2/config/openas2.properties
      - EXTRA_PARMS="-Xmx512m"
    volumes:
      #- /opt/openas2/config/personal.p12:/opt/openas2/config/personal.p12
      #- /opt/openas/config/personal.jks:/opt/openas2/config/personal.jks
      #- /opt/openas2/config/openas2.properties:/opt/openas2/config/openas2.properties
      #- /opt/openas2/config/partnerships.xml:/opt/openas2/config/partnerships.xml
      #- /opt/openas2/config/DB:/opt/openas2/config/DB
      - /opt/openas2/config:/opt/openas2/config
      - /opt/openas2/data:/opt/openas2/data
      - /opt/openas2/logs:/opt/openas2/logs
    tty: true
    stdin_open: true
    restart: always
uhurusurfa commented 8 months ago

You can put the partnerships XML file and openas2.properties file somewhere like: /opt/MyAS2Config In the openas2.properties file make sure you have: partnership_file=/opt/MyAS2Config/partnerships.xml Then in the docker file set OPENAS2_PROPERTIES_FILE to /opt/MyAS2Config/openas2.properties And set the volume so that /opt/MyAS2Config is accessible from the container.

sonykphilip commented 8 months ago

Yes, this is exactly what I did and raised this issue about the properties file getting overwritten with this method.

`The partnerships.xml is a volume mount in the docker-compose.yaml:

volumes:

In the /opt/openas2/config/openas2.properties: partnership_file=/opt/openas2/config/partnerships.xml

environment:

If you see my latest config, everything that mounts a specific file has now been commented out and Ive added the 'config' directory as a mount instead: - /opt/openas2/config:/opt/openas2/config

ThorTL67 commented 8 months ago

I'm testing with 3.7 and have this as my volume:

    volumes:
      - ./Server/src/config:/opt/openas2/config

The config files including partnerships are persisting.

I ran into the same issue regarding #332 but found that the partnership export from the WEBUI was producing a weird partnerships xml, I don't think it's related to this