Alfresco / alfresco-docker-installer

Generator to build Docker Compose templates to deploy Alfresco Community
Other
143 stars 57 forks source link

Connecting external MySQL database #198

Open ammxr opened 5 months ago

ammxr commented 5 months ago

If I have a locally running instance of a MySQL database how can I connect it to Alfresco CE? I already have the default containerized MariaDB working fine with Alfresco though my concern is moreso connecting a separate non-containerized MySQL server.

Given that its a separate running instance I'd assume changing just the URL and the Driver variables within the docker-compose.yml and removing the mariadb container woud be enough.

No specific log files are generated though here is my terminal on attempt of execution: docker_compose_up_terminal.txt

For reference here is also my docker-compose.yml. The URL/Driver within should be correct as it is directly copied off a different working ECM installation.

version: "2"

services:
    alfresco:
        build:
          context: ./alfresco
          args:
            ALFRESCO_TAG: ${ALFRESCO_CE_TAG}
            DB: mariadb
            SOLR_COMMS: secret 
        mem_limit: 7488m
        environment:
            JAVA_TOOL_OPTIONS: "
                -Dencryption.keystore.type=JCEKS
                -Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding
                -Dencryption.keyAlgorithm=DESede
                -Dencryption.keystore.location=/usr/local/tomcat/shared/classes/alfresco/extension/keystore/keystore
                -Dmetadata-keystore.password=mp6yc0UD9e
                -Dmetadata-keystore.aliases=metadata
                -Dmetadata-keystore.metadata.password=oKIWzVdEdA
                -Dmetadata-keystore.metadata.algorithm=DESede
                "
            JAVA_OPTS : '
                -Ddb.username=alfresco
                -Ddb.password=alfresco 
                -Ddb.driver=com.mysql.cj.jdbc.Driver
                -Ddb.url=jdbc:mysql://127.0.0.1:3306/alfresco?useUnicode=yes&characterEncoding=UTF-8 
                -Dalfresco_user_store.adminpassword=209c6174da490caeb422f3fa5a7ae634
                -Dsystem.preferred.password.encoding=bcrypt10
                -Dsolr.host=solr6
                -Dsolr.port=8983
                -Dsolr.port.ssl=8983
                -Dsolr.secureComms=secret
                -Dsolr.baseUrl=/solr
                -Dindex.subsystem.name=solr6
                -Dsolr.sharedSecret=robbbl08y0b  
                -Dalfresco.host=${SERVER_NAME}
                -Dalfresco.port=80
                -Dapi-explorer.url=http://${SERVER_NAME}:80/api-explorer
                -Dalfresco.protocol=http 
                -Dshare.host=${SERVER_NAME}
                -Dshare.port=80
                -Dshare.protocol=http 
                -Daos.baseUrlOverwrite=http://${SERVER_NAME}/alfresco/aos 
                -Dmessaging.subsystem.autoStart=false
                -Drepo.event2.enabled=false
                -Ddeployment.method=DOCKER_COMPOSE
                -Dcsrf.filter.enabled=false 
                -Dopencmis.server.override=true
                -Dopencmis.server.value=http://${SERVER_NAME}:80
                -DlocalTransform.core-aio.url=http://transform-core-aio:8090/
                -Dhttpclient.config.transform.connectionRequestTimeout=500000
                -Dcsrf.filter.enabled=false
                -Dalfresco.restApi.basicAuthScheme=true
                -Dauthentication.protection.enabled=false
                -XX:+UseG1GC -XX:+UseStringDeduplication
                -Dgoogledocs.enabled=false  
                -Ddev.email.not.sent=true  
                -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80
            '
        volumes: 
            - ./data/alf-repo-data:/usr/local/tomcat/alf_data
            - ./logs/alfresco:/usr/local/tomcat/logs    

    transform-core-aio:
        image: alfresco/alfresco-transform-core-aio:${TRANSFORM_ENGINE_TAG}
        restart: on-failure
        mem_limit: 2048m
        environment:
            JAVA_OPTS: "
              -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80
              -Dserver.tomcat.threads.max=12
              -Dserver.tomcat.threads.min=4
              -Dlogging.level.org.alfresco.transform.common.TransformerDebug=ERROR
              -Dlogging.level.org.alfresco.transform=ERROR
              -Dlogging.level.org.apache.fontbox.ttf=ERROR
              -Dlogging.level.org.apache.pdfbox.cos.COSDocument=ERROR
              -Dlogging.level.org.apache.pdfbox.pdfparser=ERROR
              -Dlogging.level.org.apache.pdfbox.filter.FlateFilter=ERROR
              -Dlogging.level.org.apache.pdfbox.pdmodel.font=ERROR
              -Dlogging.level.org.apache.pdfbox.pdmodel.font.PDSimpleFont=FATAL
              -Dlogging.level.org.apache.pdfbox.pdmodel.font.PDFont=FATAL
              -Dlogging.level.org.apache.pdfbox.pdmodel.font.PDCIDFont=FATAL
            "

    share:
        build:
          context: ./share
          args:
            SHARE_TAG: ${SHARE_TAG}
            SERVER_NAME: ${SERVER_NAME}
        mem_limit: 1872m
        environment:
            REPO_HOST: "alfresco"
            REPO_PORT: "8080"
            CSRF_FILTER_REFERER: "http://localhost:80/.*"
            CSRF_FILTER_ORIGIN: "http://localhost:80"
            JAVA_OPTS: "
                -Dalfresco.context=alfresco
                -Dalfresco.protocol=http
                -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80
                "
        volumes: 
            - ./logs/share:/usr/local/tomcat/logs  

    solr6:
        build:
          context: ./search
          args:
            SEARCH_TAG: ${SEARCH_CE_TAG}
            SOLR_HOSTNAME: solr6
            ALFRESCO_HOSTNAME: alfresco
            ALFRESCO_COMMS: secret 
            CROSS_LOCALE: "true"
            DISABLE_CONTENT_INDEXING: "false"
        mem_limit: 3744m
        environment:
            SOLR_JAVA_MEM: "-XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80"
            #Solr needs to know how to register itself with Alfresco
            SOLR_ALFRESCO_HOST: "alfresco"
            SOLR_ALFRESCO_PORT:  "8080" 
            #Alfresco needs to know how to call solr
            SOLR_SOLR_HOST: "solr6"
            SOLR_SOLR_PORT: "8983"
            #Create the default alfresco and archive cores
            SOLR_CREATE_ALFRESCO_DEFAULTS: "alfresco,archive" 
            SOLR_OPTS: "
                -XX:-UseLargePages
                -Dalfresco.secureComms.secret=robbbl08y0b 
            "
        volumes: 
            - ./data/solr-data:/opt/alfresco-search-services/data   

    content-app:
        image: alfresco/alfresco-content-app:${ACA_TAG}
        mem_limit: 256m
        environment:
            APP_BASE_SHARE_URL: "http://${SERVER_NAME}:80/#/preview/s"
        depends_on:
            - alfresco

    # HTTP proxy to provide HTTP Default port access to services
    # SOLR API and SOLR Web Console are protected to avoid unauthenticated access
    proxy:
        image: nginx:stable-alpine
        mem_limit: 128m
        depends_on:
            - alfresco
            - solr6
            - share
            - content-app
        volumes:
            - ./config/nginx.conf:/etc/nginx/nginx.conf
            - ./config/nginx.htpasswd:/etc/nginx/conf.d/nginx.htpasswd 
        ports:
            - 80:80

Would appreciate any help!

aborroy commented 5 months ago

This line is wrong:

-Ddb.url=jdbc:mysql://127.0.0.1:3306/alfresco?useUnicode=yes&characterEncoding=UTF-8 

Inside a Docker container, 127.0.0.1 refers specifically to the container's own loopback interface, not the host machine's localhost. This means that when your alfresco container tries to connect to 127.0.0.1:3306, it's attempting to connect to a service running on the same network as the container itself, not the database service on the host machine.

Use your host machine local ip instead of 127.0.0.1

ammxr commented 5 months ago

Thanks! Yeah I was testing that internally on the same machine though I now have it available to connect from any IP and have tested it on another machine as well. In terms of Alfresco however, I am getting the same output in the console after your corrections/updates to the DB connection:

            JAVA_OPTS : '
                -Ddb.username=alfresco2
                -Ddb.password=alfresco2
                -Ddb.driver=com.mysql.cj.jdbc.Driver
                -Ddb.url=jdbc:mysql://10.0.0.39:3306/alfresco?useUnicode=yes&characterEncoding=UTF-8

Also the SOLR issues remain as well even when using the default containerized MariaDB Alfresco is running just fine (Error still exists but everything seemingly functions fine) so I don't think thats an issue related to the DB not working.

Here is the full updated terminal + docker-compose.yml docker_compose_up_terminal.txt docker-compose.txt

And still no logs are generated

aborroy commented 5 months ago

If you are using Windows/Linux as host for Docker, review volumes recommendations in https://github.com/Alfresco/alfresco-docker-installer?tab=readme-ov-file#docker-volumes