Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic image for nexus3 image with composer plugin #155

Open
Timotej979 opened this issue Jun 7, 2024 · 0 comments
Open

Dynamic image for nexus3 image with composer plugin #155

Timotej979 opened this issue Jun 7, 2024 · 0 comments

Comments

@Timotej979
Copy link

Timotej979 commented Jun 7, 2024

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 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant