sonatype-nexus-community / nexus-repository-composer

Composer support for the Nexus Repository Manager (work in progress!)
Eclipse Public License 1.0
211 stars 82 forks source link

Dynamic image for nexus3 image with composer plugin #155

Open Timotej979 opened 1 month ago

Timotej979 commented 1 month ago

What are you trying to do?

Build a dynamic image for nexus with composer plugin

What feature or behavior is this required for?

Easy updates of the image to newer versions and migrations, template for future releases.

How could we solve this issue? (Not knowing is okay!)

Currently the image builds correctly, however the recepies for composer repositories are not present in the Nexus repository manager UI. However we are using the latest version of sonatype/nexus3 version with java8 and the latest compose plugin version of 0.0.29. Is there a limit on which nexus3 image the composer works?

Here is the current Dockerfile that I`m using:

ARG NEXUS_VERSION=3.69.0-java8
FROM sonatype/nexus3:${NEXUS_VERSION}

ARG COMPOSER_PLUGIN_VERSION=0.0.29

USER root

# Install necessary tools using microdnf
RUN microdnf install -y curl unzip && microdnf clean all

# Define plugin paths
ENV NEXUS_DIR=/opt/sonatype/nexus
ENV COMPOSER_PLUGIN_PATH=${NEXUS_DIR}/system/org/sonatype/nexus/plugins/nexus-repository-composer/${COMPOSER_PLUGIN_VERSION}
ENV NEXUS_CORE_FEATURE_PATH=${NEXUS_DIR}/system/org/sonatype/nexus/assemblies/nexus-core-feature

# Create necessary directories and set permissions
RUN mkdir -p ${COMPOSER_PLUGIN_PATH}

# Download and install the Composer plugin
RUN curl -L -o ${COMPOSER_PLUGIN_PATH}/nexus-repository-composer-${COMPOSER_PLUGIN_VERSION}.jar \
    https://github.com/sonatype-nexus-community/nexus-repository-composer/releases/download/${COMPOSER_PLUGIN_VERSION}/nexus-repository-composer-${COMPOSER_PLUGIN_VERSION}.jar

# Update the plugin configuration in the features.xml file as root
RUN for FEATURES_XML in ${NEXUS_CORE_FEATURE_PATH}/*/nexus-core-feature-*-features.xml; do \
        sed -i '/<feature name="nexus-core-feature"/a\    <feature prerequisite="false" dependency="false">nexus-repository-composer</feature>' $FEATURES_XML && \
        sed -i '/<\/features>/i\  <feature name="nexus-repository-composer" description="org.sonatype.nexus.plugins:nexus-repository-composer" version="'${COMPOSER_PLUGIN_VERSION}'">\n    <details>org.sonatype.nexus.plugins:nexus-repository-composer</details>\n    <bundle>mvn:org.sonatype.nexus.plugins/nexus-repository-composer/'${COMPOSER_PLUGIN_VERSION}'</bundle>\n  </feature>' $FEATURES_XML; \
    done

# Change ownership back to nexus user
RUN chown -R nexus:nexus ${NEXUS_DIR}/system/org/sonatype/nexus/plugins && \
    chown -R nexus:nexus ${NEXUS_DIR}/system/org/sonatype/nexus/assemblies

USER nexus

EXPOSE 8081

ENTRYPOINT ["/opt/sonatype/nexus/bin/nexus", "run"]

Thanks for the help it is very much appreciated :smile: