Skip to content

Painless WildFly datasources in Docker #5

@sfcoy

Description

@sfcoy

There is no need to start WildFly up in order to set up a data source.

Create a cli script named install-ds.cli similar to:

# Execute offline
embed-server --server-config=standalone.xml

deploy postgresql-42.1.1.jre7.jar

# Add the application datasource
data-source add \
    --name=BloggoDS \
    --driver-name=postgresql-42.1.1.jre7.jar \
    --connection-url=jdbc:postgresql://bloggodb:5432/bloggodb \
    --jndi-name=java:jboss/datasources/BloggoDS \
    --user-name=bloggo \
    --password=password \
    --use-ccm=false \
    --min-pool-size=10 \
    --max-pool-size=25 \
    --pool-prefill=true \
    --blocking-timeout-wait-millis=5000 \
    --new-connection-sql="set datestyle = ISO, European;"

and add the following fragment to your Dockerfile:

RUN curl -L -O https://repo1.maven.org/maven2/org/postgresql/postgresql/42.1.1.jre7/postgresql-42.1.1.jre7.jar
COPY install-ds.cli bin/
RUN bin/jboss-cli.sh --file="bin/install-ds.cli" && rm postgresql-42.1.1.jre7.jar

Adjust for the version of the driver and actual datasource names that you want. I don't bother with adding a module for the driver because it adds unnecessary complexity.

Cheers,

@sfcoy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions