How to configure a GlassFish instance running on AWS/ElasticBeanstalk/Docker?

后端 未结 2 1476
时光取名叫无心
时光取名叫无心 2021-01-12 04:02

I\'m using GlassFish to serve up a Java EE web app. Things are working fine on my local dev machine. I have

  • copied postgres JDBC libraries into the right place
2条回答
  •  無奈伤痛
    2021-01-12 04:42

    After struggling with this myself for sometime, I think I have finally found an acceptable workaround (atleast for me) as follows :-

    Create DockerFile and package it directly inside the WAR (at the highest level, not in any folder). DockerFile -

    # Use the AWS Elastic Beanstalk Glassfish image
    FROM        amazon/aws-eb-glassfish:4.1-jdk8-onbuild-3.5.1
    
    # Exposes port 8080
    EXPOSE      8080 4848 8181
    
    # Install Datasource dependencies
    RUN         curl -L -o /tmp/connectorj.zip https://server/path/connectorj.zip && \
                unzip /tmp/connectorj.zip -d /tmp && \
                cp /tmp/connectorj/mysql-connector-java-5.1.36-bin.jar /usr/local/glassfish4/glassfish/domains/domain1/lib/ && \
                mv /var/app/WEB-INF/classes/domain.xml /usr/local/glassfish4/glassfish/domains/domain1/config/
    

    Now when this WAR is deployed (I am using 'eb deploy'). This DockerFile is executed.

    In the simple example above - first mysql jdbc driver is downloaded and setup into glassfish's lib directory. Next I have packaged domain.xml (all the resources, etc already setup) inside the WAR itself, gets moved to glassfish's domain config folder to be loaded when glassfish will start.

提交回复
热议问题