Search code examples
kubernetesdockerfileartifactorykubernetes-helmpersistent-volume-claims

Is it possible to bootstrap Artifactory-OSS Docker image with Kubernetes Deployment and PVC?


We want to run bootstrap the default artifactory.config.xml and security.import.xml files to pre-define our users and repositories.

We'd also like to use persistent storage, specifically a PVC, to persist artifacts between container restarts.

According to their documentation, you can setup extra config by placing config file into artifactory_extra_config and they will be copied into the $ARTIFACTORY_HOME/etc directory at container start. However, this does not seem to be the case for Artifactory OSS.

According to the Helm chart: Bootstrapping Artifactory IMPORTANT: Bootstrapping Artifactory needs license. Pass license as shown in above section.

Documentation also mentions that placing artifactory.config.import.xml and security.import.xml in the $ARTIFACTORY_HOME/etc directory allows for bootstrapping.

We have built a custom docker image from the Artifactory-oss:6.1.0 base image and simply copy two config files to the $ARTIFACTORY_HOME/etc directory, but attaching a PVC at /var/opt/jfrog/artifactory seems to overwrite the config causing the bootstrap to fail.

I found that the Helm chart mounts a ConfigMap containing the bootstrap config files to a /bootstrap/ volume and copies them to /artifactory_extra_conf in the lifecycle.postStart command. This does not appear to work either.

I've noticed that the ENV for Artifactory PRO base image contains ARTIFACTORY_EXTRA_CONF=/artifactory_extra_confwhile Artifactory OSS does not.

I've also attempted some experiments copy the config files in our custom image to other directories and copying loading the volume using initContainers, but so far nothing I've tried has allowed me to bootstrap Arrtifactory OSS AND use a persistent volume mounted at /var/opt/jfrog/artifactory.

I noted in the Dockerfile for Artifactory that the /var/opt/jfrog/artifactory sub directories are actually linked to the corresponding /opt/jfrog/artifactory directories in the base image.


Solution

  • Our solution was to modify their /entrypoint-artifactory.sh and create a custom image.

    First, we added a new function copyExtraConf() to /etnrypoint-artifactory.sh

    copyExtraConf () {
        logger "Copying from artifactory_extra_conf"
        chown ${ARTIFACTORY_USER_NAME}:${ARTIFACTORY_USER_NAME} /artifactory_extra_conf/*
        cp -pv /artifactory_extra_conf/* ${ARTIFACTORY_HOME}/etc/
    }
    

    Then we called it after we've setup directories and users to prevent ownership errors of a mounted volume:

    printDockerFileLocation
    checkULimits
    checkMounts
    setupDataDirs
    setupArtUser
    
    # CUSTOM:START - do this after setupDataDirs and setupArtUser so we can chown and copy our files.
    copyExtraConf
    # CUSTOM:END
    
    setAccessCreds
    setMasterKey
    setupPermissions
    setDBType
    addExtraJavaArgs
    

    Dockerfile:

    # Dockerfile
    #
    # NOTE:
    # entrypoint-artifactory.sh is based on the one from artifactory-oss:6.1.0
    # When changing versions, be sure to compare entrypoint-artifactory-ta.sh to entrypoint-artifactory.sh
    FROM docker.bintray.io/jfrog/artifactory-oss:6.1.0
    
    COPY entrypoint-artifactory.sh /entrypoint-artifactory.sh
    RUN chmod +x /entrypoint-artifactory.sh
    
    ENTRYPOINT ["/entrypoint-artifactory.sh"]
    
    COPY configs/artifactory.config.import.xml /artifactory_extra_conf/artifactory.config.import.xml
    COPY configs/security.import.xml /artifactory_extra_conf/security.import.xml