I'm trying to run artifactory-oss in openshift with configuration of PostgreSQL database . I have the following Dockerfile, which I build using kaniko in the GitLab CI/CD pipeline:
FROM docker.bintray.io/jfrog/artifactory-oss:latest
ENV ARTIFACTORY_HOME=/var/opt/jfrog/artifactory
VOLUME /var/opt/jfrog/artifactory
VOLUME /data/artifactory
# Handle group creation to avoid errors if the group already exists
RUN groupadd -f artifactory && \
useradd -g artifactory -d $ARTIFACTORY_HOME -u 999 artifactory || true
RUN mkdir -p $ARTIFACTORY_HOME/{data,logs,backup} && \
chown -R artifactory: $ARTIFACTORY_HOME/{data,logs,backup}
ADD $ARTIFACTORY_HOME/etc/db.properties .
# Copy custom database configuration to the Artifactory config directory
COPY db.properties $ARTIFACTORY_HOME/etc/db.properties
RUN echo $(ls -1 $ARTIFACTORY_HOME/etc/)
RUN echo $(tail -n 10 $ARTIFACTORY_HOME/etc/db.properties)
# Set PostgreSQL environment variables
ENV DB_TYPE=postgresql
ENV DB_HOST=$DB_HOST
ENV DB_PORT=6601
ENV DB_USER=artifactory
ENV DB_PASSWORD=$ARTIFACTORY_DB_PASSWORD
#ENV DB_NAME=artifactory
ENV VIRTUAL_PORT=443
EXPOSE 8081
USER artifactory
ENTRYPOINT ["/entrypoint-artifactory.sh"]
EXPOSE 8081
The Docekerfile is built and then deployed using the following GitLab CI/CD pipeline:
stages:
- dockerize
- deploy
variables:
SERVER: $OPENSHIFT_SERVER
NAMESPACE: hse-artifactory
dockerize:
stage: dockerize
image:
name: ${GITLAB_REGISTRY_HOST}/ci-tools/docker-image-builder
entrypoint: [ "" ]
variables:
IMAGE_DESTINATION: ${CI_REGISTRY_IMAGE}/openshift-artifactory-oss:latest
script:
# Prepare Kaniko configuration file
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
# Build and push the image from the Dockerfile at the root of the project.
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $IMAGE_DESTINATION --build-arg SPRING_PROFILES_ACTIVE=$SPRING_PROFILES_ACTIVE --build-arg ARTIFACTORY_DB_PASSWORD=$ARTIFACTORY_DB_PASSWORD
- echo "Image pushed successfully to ${IMAGE_DESTINATION}"
when: on_success
deploy:
stage: deploy
image: ${GITLAB_REGISTRY_HOST}/paas-tools/openshift-client:latest
variables:
APP_NAME: openshift-artifactory-oss
script:
- "oc import-image $APP_NAME --all --server=$SERVER --namespace $NAMESPACE --token=$IMAGE_IMPORT_TOKEN"
- "sleep 15s && oc rollout status deployment/$APP_NAME --server=$SERVER --namespace $NAMESPACE --token=$IMAGE_IMPORT_TOKEN"
needs:
- dockerize
when: manual
The build is executed successfully in GitLab, then the image is published in GitLab registry and then deployed to the openshift. When I check the logs of the pod in openshift, I see following message:
Preparing to run Artifactory in Docker
Running as uid=1017250000(1017250000) gid=0(root) groups=0(root),1017250000
Dockerfile for this image can found inside the container.
To view the Dockerfile: 'cat /docker/artifactory-oss/Dockerfile.artifactory'.
Copying Artifactory bootstrap files
2024-07-09T14:51:01.587Z [shell] [INFO ] [] [installerCommon.sh:3553 ] [main] - Mapping value from deprecated key DB_TYPE to new key JF_SHARED_DATABASE_TYPE
2024-07-09T14:51:01.647Z [shell] [INFO ] [] [installerCommon.sh:3553 ] [main] - Mapping value from deprecated key DB_HOST to new key JF_SHARED_DATABASE_HOST
2024-07-09T14:51:01.705Z [shell] [INFO ] [] [installerCommon.sh:3553 ] [main] - Mapping value from deprecated key DB_PORT to new key JF_SHARED_DATABASE_PORT
2024-07-09T14:51:01.794Z [shell] [INFO ] [] [installerCommon.sh:3553 ] [main] - Mapping value from deprecated key DB_USER to new key JF_SHARED_DATABASE_USER
2024-07-09T14:51:02.081Z [shell] [INFO ] [] [installerCommon.sh:1617 ] [main] - Checking open files and processes limits
2024-07-09T14:51:02.106Z [shell] [INFO ] [] [installerCommon.sh:1620 ] [main] - Current max open files is 1048576
2024-07-09T14:51:02.132Z [shell] [INFO ] [] [installerCommon.sh:1631 ] [main] - Current max open processes is 4194304
[WARN ] Error while initializing File resolver : Config file does not exists : /opt/jfrog/artifactory/var/etc/system.yaml
Database connection check failed Could not determine database type
2024-07-09T14:51:02.233Z [shell] [INFO ] [] [installerCommon.sh:1700 ] [main] - Testing directory /opt/jfrog/artifactory/var has read/write permissions for user id 1017250000
2024-07-09T14:51:02.261Z [shell] [INFO ] [] [installerCommon.sh:1715 ] [main] - Permissions for /opt/jfrog/artifactory/var are good
...
So looks like data base connection is not configured correctly: Database connection check failed Could not determine database type
. According to artifactory documentation, the database configuration is loaded from db.properties
file which I copy in Dockerfile file:
COPY db.properties $ARTIFACTORY_HOME/etc/db.properties
However, when I check if db.properties
exists in the openshfit pod of deployed artifcatory, I can't find it.
Do you know what is wrong in my Dockerfile/GitLab CI/CD config? Why is my db.properties
file not copied to openshift?