Giter Club home page Giter Club logo

Comments (15)

zazu86 avatar zazu86 commented on August 18, 2024 2

Great!
Thanks! Unfortunately I cannot use it, I will have to revise it for kubernetes,
I would like to share my observations and my work (even if very small compared to OpenAS2) with the community.
I would be very happy if my suggestions will be useful to the project or to anyone.

1.
inside the container there are Docker volumes, they are a nightmare, the data ends up in paths that are difficult to manage.
These are not compatible with kubernetes in any way because being local objects, they are tied to the specific node where the container is instantiated and they are not cluster-wide.
so their use on kubernetes is wrong by design
in addition, you cannot have access to that file system level inside the kube instances in the managed cloud, so you cannot manage or remove the docker volumes, which in some cases can saturate the space of the node causing it to crash!

True on kubernetes you can override paths and volumes by mounting whatever you want in their place, but the data inside them is lost (hidden by overlay mounting).
With the container structured in this way, inside kubernetes the configuration files must be managed one by one with config maps or other systems.

In my opinion, the best strategy that allows a versatile use in every situation is to avoid the presence of builtin volumes because it is very simple to map some specific paths at runtime.
Obviously it is good that these details are well documented on the docker-hub repo (and why not in the official documentation).

For example, without volumes, it is possible to have all data in persistent folders on the machine:

docker run -d --restart=unless-stopped --name OpenAS2 \
    -v /opt/OpenAS2/data:/usr/src/openas2/Runtime/data \
    -v /opt/OpenAS2/config:/usr/src/openas2/Runtime/config \
    -v /opt/OpenAS2/logs:/usr/src/openas2/Runtime/logs \
    openas2:2.11.0

so instead of volumes, we would have all the static data in /opt/OpenAS2, it is much easier to keep under control.

2.
from this page I understand that openjdk9 is not in the list of actively developed containers.
https://github.com/docker-library/docs/blob/master/openjdk/README.md#supported-tags-and-respective-dockerfile-links
it's usually best to base your containers on active branches
Unfortunately I don't know if OpenAS2 is able to run on new versions of openjdk (or zulu openjdk) and I haven't done any tests due to lack of time.

3.
I saw that the final container is quite large (1.58GB), in my opinion you could try a different approach to generate it, which allows you to reduce it to 409MB

based on your work I created this simple Dockerfile:

FROM openjdk:9 AS builder
COPY . /usr/src/openas2
WORKDIR /usr/src/openas2
RUN rm -f Server/dist/*
RUN rm -f Remote/dist/*
RUN rm -f Bundle/dist/*
RUN ./mvnw clean package
RUN mkdir ./Runtime && unzip Server/dist/OpenAS2Server-*.zip -d Runtime
RUN ./mvnw clean
COPY start-container.sh /usr/src/openas2/Runtime/bin/
RUN cd /usr/src/openas2/Runtime/bin && \
    chmod 755 *.sh && \
    cd /usr/src/openas2/Runtime && \
    mv config config_template

FROM openjdk:9.0.4-slim
COPY --from=builder /usr/src/openas2/Runtime /usr/src/openas2/Runtime
WORKDIR /usr/src/openas2/Runtime
ENTRYPOINT /usr/src/openas2/Runtime/bin/start-container.sh

after the build stage, this generates a container from openjdk: 9.0.4-slim.
At the level of openjdk it seems to me that there are no differences, but it is based on a much smaller starting image.

in addition to the dockerfile, I have created this very simple script "start-container.sh" that must be inserted in the container, since I have deleted the volumes from the Dockerfile, this is used to manage the first run in case of empty config folder.

#!/bin/sh

if [ ! -e /usr/src/openas2/Runtime/config/config.xml ]
    then
        echo "The config folder is empty, it will be populated by the template..."
        cd config_template
        cp -a * ../config/
        echo "Done!"
fi
$(dirname $0)/start-openas2.sh

I hope it can help someone

Cheers,
S.

from openas2app.

igwtech avatar igwtech commented on August 18, 2024 1

I uploaded a Docker image to Docker Hub
https://hub.docker.com/repository/docker/greicodex/openas2

from openas2app.

igwtech avatar igwtech commented on August 18, 2024

from openas2app.

igwtech avatar igwtech commented on August 18, 2024

More details:
I currently test the build process on MacOS using a Vagrant container for OpenAS2. I could share my Vagrant file if you want it.
However I'm planing to create a publish a proper container for OpenAS2 with external volumes for data and config in Docker Hub.

from openas2app.

VboxNick avatar VboxNick commented on August 18, 2024

Sounds good, thanks. Please, share somehow your Dockerfile I'd like to have a look

from openas2app.

igwtech avatar igwtech commented on August 18, 2024

FROM openjdk:9
COPY . /usr/src/openas2
WORKDIR /usr/src/openas2
RUN ./mvnw clean package
RUN mkdir ./Runtime && unzip Server/dist/OpenAS2Server-*.zip -d Runtime
RUN ./mvnw clean
CMD ["bash", "/usr/src/openas2/Runtime/bin/start-openas2.sh"]
VOLUME ["/usr/src/openas2/Runtime/data","/usr/src/openas2/Runtime/config"]

from openas2app.

pedro9bee avatar pedro9bee commented on August 18, 2024

Hi igwtech, I am newbie in docker and in OpenAs2.
I read the documentation and I Need to change config.xml, partners.xml and commands.xml. I used your image and works great, but when I want to change this files, how can I do ?

from openas2app.

pedro9bee avatar pedro9bee commented on August 18, 2024

On MacOs Catalina ... where volumes are created ?

from openas2app.

igwtech avatar igwtech commented on August 18, 2024

from openas2app.

zazu86 avatar zazu86 commented on August 18, 2024

Hello, good evening,
I am interested in running OpenAS2 on Kubernetes;

reading this thread I realized that it works well starting from an openjdk:9 container
(however openjdk is not mentioned in the documentation, where it is specified that Oracle java is needed).

@igwtech in your docker repository there is no latest release 2.11.0
I would like to ask if it is possible to generate a container with the latest stable release of OpenAS2 starting from openjdk:9.
Can I use the dockerfile in the repo or are there any differences to consider?

Thank you

from openas2app.

igwtech avatar igwtech commented on August 18, 2024

from openas2app.

igwtech avatar igwtech commented on August 18, 2024

from openas2app.

zazu86 avatar zazu86 commented on August 18, 2024

Hello,

I am currently evaluating the use of OpenAS2 to replace a very old RSSBus AS2 connector, I need it on a single customer and for a single data stream with few weekly transfers;

In reality, I am not very knowledgeable about AS2 transfers, because it is not a type of product usually administered by me and in all honesty, OpenAS2 is not even very easy to configure, of course, this is because it is rich in options and features, which make it a product not "ready to use for dummies" :-D
I don't have to manage a large amount of messages.

The problem I described is strictly related to the use of Docker volumes, not so much because OpenAS2 depends on some paths on the filesystem (which is normal for many products), but because the docker container structured with docker volumes does not work well on kubernetes, where they are there are different ways to manage persistent volumes.

In summary, I wanted to mean that a well structured container is more easily usable on both docker and kubernetes.

on the other hand, as regards the possibility of managing the data flow on a message queue, it could be interesting
for example if we talk about kafka, I could submit this information and the possible price to my company.
I'm not the one to decide on any budget to allocate.

Cheers,
S.

from openas2app.

igwtech avatar igwtech commented on August 18, 2024

from openas2app.

zazu86 avatar zazu86 commented on August 18, 2024

Hello,

of course, you can include all this in the project, you have my permission,
the container startup script was written quickly and is a bit rudimentary,
I think it should be enriched with some further checks, it would be better to check more precisely the need to populate the config from the template.

Ok, openAS2 was written in a pre-cloud era, however it is not that far from the working models of many other applications,
totally stateless applications are very rare,
almost all apps need some configuration file, or at least some environment variables!

In order to facilitate a transaction to Docker, I notice that there is not a section in the doc that specifies which communication ports must be opened on the container.

While for Volumes, there are now three areas that need the filesystem:

logs
config
data

Removing logs from filesystems is a big step forward for a container, and it already seems possible to me, OpenAS2 is already able to log on stdout / console and by setting the value file.logger.enabled = "false" this should stop to write files right?
console.logger.enabled = "true" causes all logs to be printed on screen?

In the container this should be the default setting,
the optional enabling of persistent logs on files, always in my opinion should remain, in some scenarios it could be useful.

data can be removed from filesystems only by implementing systems such as kafka jms or other, which as you explained to me can already be implemented as an extension

As for the config, I believe that outsourcing them to a DB does not solve the problem, it simply moves it elsewhere, instead of having a static filesystem you must have (and keep operational) an external database

in a kubernetes perspective, the configuration files can be stateless in the container, this is because kubernetes keeps track of these in the configmaps and writes them in the container at each start, overriding any template files

I saw that in the config there is a DB, this I suspect is updated by the software over time and it is necessary to keep it persistent during reboots right?

if you use docker, as I explained a few posts ago, you can simply mount a folder on the host machine.

Cheers,
S.

from openas2app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.