Creating a repository and uploading artifacts to a Nexus3 docker container










0















This is basically a two part question.



First I would like to know how I would go about creating a new repository on a Nexus3 container after the container starts up. I know the rough outline on what has to be done, I just dont know how to do it.
Basically, two cURL requests have to be sent to the container AFTER it is ready. The cURL requests are as follows:



curl -X POST -u admin:admin123 --header 'Content-Type: application/json' 
http://127.0.0.1:8081/service/rest/v1/script
-d '"name":"newrepo","type":"groovy","content":"repository.createMavenHosted('''new-repo''');"'

curl -X POST -u admin:admin123 --header "Content-Type: text/plain" 'http://127.0.0.1:8081/service/rest/v1/script/newrepo/run'


(The above curl requests work when I manually send them via an app like Postman AFTER the container is ready. I am just unsure on how to make docker do it for me)



Secondly, I would like to know how to move artifacts to the newly created repository. Is there a location on the nexus3 image where I can just execute a COPY command and just copy the required artifacts to the repository?



Below is part of my docker-compose.yml



version: "2.1"
services:
nexus:
container_name: nexus-container
image: sonatype/nexus3
ports:
- "8081:8081"


This is just part of the entire file as the entire file a bit bigger therefore I did not want to post the entire thing, but I can do so if needed.



Thanks for any assistance provided :)










share|improve this question






















  • It is unclear what you want to achieve. Why can't you create the repo after the container is up? (e.g. via the UI)

    – Henry
    Nov 12 '18 at 12:09











  • The requirement is such that the repository should be created once the container starts up

    – user538578964
    Nov 12 '18 at 12:10











  • Is it not possible to achieve the requirements? @Henry

    – user538578964
    Nov 12 '18 at 15:15















0















This is basically a two part question.



First I would like to know how I would go about creating a new repository on a Nexus3 container after the container starts up. I know the rough outline on what has to be done, I just dont know how to do it.
Basically, two cURL requests have to be sent to the container AFTER it is ready. The cURL requests are as follows:



curl -X POST -u admin:admin123 --header 'Content-Type: application/json' 
http://127.0.0.1:8081/service/rest/v1/script
-d '"name":"newrepo","type":"groovy","content":"repository.createMavenHosted('''new-repo''');"'

curl -X POST -u admin:admin123 --header "Content-Type: text/plain" 'http://127.0.0.1:8081/service/rest/v1/script/newrepo/run'


(The above curl requests work when I manually send them via an app like Postman AFTER the container is ready. I am just unsure on how to make docker do it for me)



Secondly, I would like to know how to move artifacts to the newly created repository. Is there a location on the nexus3 image where I can just execute a COPY command and just copy the required artifacts to the repository?



Below is part of my docker-compose.yml



version: "2.1"
services:
nexus:
container_name: nexus-container
image: sonatype/nexus3
ports:
- "8081:8081"


This is just part of the entire file as the entire file a bit bigger therefore I did not want to post the entire thing, but I can do so if needed.



Thanks for any assistance provided :)










share|improve this question






















  • It is unclear what you want to achieve. Why can't you create the repo after the container is up? (e.g. via the UI)

    – Henry
    Nov 12 '18 at 12:09











  • The requirement is such that the repository should be created once the container starts up

    – user538578964
    Nov 12 '18 at 12:10











  • Is it not possible to achieve the requirements? @Henry

    – user538578964
    Nov 12 '18 at 15:15













0












0








0








This is basically a two part question.



First I would like to know how I would go about creating a new repository on a Nexus3 container after the container starts up. I know the rough outline on what has to be done, I just dont know how to do it.
Basically, two cURL requests have to be sent to the container AFTER it is ready. The cURL requests are as follows:



curl -X POST -u admin:admin123 --header 'Content-Type: application/json' 
http://127.0.0.1:8081/service/rest/v1/script
-d '"name":"newrepo","type":"groovy","content":"repository.createMavenHosted('''new-repo''');"'

curl -X POST -u admin:admin123 --header "Content-Type: text/plain" 'http://127.0.0.1:8081/service/rest/v1/script/newrepo/run'


(The above curl requests work when I manually send them via an app like Postman AFTER the container is ready. I am just unsure on how to make docker do it for me)



Secondly, I would like to know how to move artifacts to the newly created repository. Is there a location on the nexus3 image where I can just execute a COPY command and just copy the required artifacts to the repository?



Below is part of my docker-compose.yml



version: "2.1"
services:
nexus:
container_name: nexus-container
image: sonatype/nexus3
ports:
- "8081:8081"


This is just part of the entire file as the entire file a bit bigger therefore I did not want to post the entire thing, but I can do so if needed.



Thanks for any assistance provided :)










share|improve this question














This is basically a two part question.



First I would like to know how I would go about creating a new repository on a Nexus3 container after the container starts up. I know the rough outline on what has to be done, I just dont know how to do it.
Basically, two cURL requests have to be sent to the container AFTER it is ready. The cURL requests are as follows:



curl -X POST -u admin:admin123 --header 'Content-Type: application/json' 
http://127.0.0.1:8081/service/rest/v1/script
-d '"name":"newrepo","type":"groovy","content":"repository.createMavenHosted('''new-repo''');"'

curl -X POST -u admin:admin123 --header "Content-Type: text/plain" 'http://127.0.0.1:8081/service/rest/v1/script/newrepo/run'


(The above curl requests work when I manually send them via an app like Postman AFTER the container is ready. I am just unsure on how to make docker do it for me)



Secondly, I would like to know how to move artifacts to the newly created repository. Is there a location on the nexus3 image where I can just execute a COPY command and just copy the required artifacts to the repository?



Below is part of my docker-compose.yml



version: "2.1"
services:
nexus:
container_name: nexus-container
image: sonatype/nexus3
ports:
- "8081:8081"


This is just part of the entire file as the entire file a bit bigger therefore I did not want to post the entire thing, but I can do so if needed.



Thanks for any assistance provided :)







docker docker-compose sonatype nexus3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 12:01









user538578964user538578964

488




488












  • It is unclear what you want to achieve. Why can't you create the repo after the container is up? (e.g. via the UI)

    – Henry
    Nov 12 '18 at 12:09











  • The requirement is such that the repository should be created once the container starts up

    – user538578964
    Nov 12 '18 at 12:10











  • Is it not possible to achieve the requirements? @Henry

    – user538578964
    Nov 12 '18 at 15:15

















  • It is unclear what you want to achieve. Why can't you create the repo after the container is up? (e.g. via the UI)

    – Henry
    Nov 12 '18 at 12:09











  • The requirement is such that the repository should be created once the container starts up

    – user538578964
    Nov 12 '18 at 12:10











  • Is it not possible to achieve the requirements? @Henry

    – user538578964
    Nov 12 '18 at 15:15
















It is unclear what you want to achieve. Why can't you create the repo after the container is up? (e.g. via the UI)

– Henry
Nov 12 '18 at 12:09





It is unclear what you want to achieve. Why can't you create the repo after the container is up? (e.g. via the UI)

– Henry
Nov 12 '18 at 12:09













The requirement is such that the repository should be created once the container starts up

– user538578964
Nov 12 '18 at 12:10





The requirement is such that the repository should be created once the container starts up

– user538578964
Nov 12 '18 at 12:10













Is it not possible to achieve the requirements? @Henry

– user538578964
Nov 12 '18 at 15:15





Is it not possible to achieve the requirements? @Henry

– user538578964
Nov 12 '18 at 15:15












1 Answer
1






active

oldest

votes


















0














The work directory should be on persistent storage, so you shouldn't need to recreate configuration on every startup.



https://github.com/sonatype/docker-nexus3#persistent-data



That said, if you really do need to do this it can be done via the scripting/provisioning API's:



https://github.com/sonatype/docker-nexus3#persistent-data






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261766%2fcreating-a-repository-and-uploading-artifacts-to-a-nexus3-docker-container%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The work directory should be on persistent storage, so you shouldn't need to recreate configuration on every startup.



    https://github.com/sonatype/docker-nexus3#persistent-data



    That said, if you really do need to do this it can be done via the scripting/provisioning API's:



    https://github.com/sonatype/docker-nexus3#persistent-data






    share|improve this answer



























      0














      The work directory should be on persistent storage, so you shouldn't need to recreate configuration on every startup.



      https://github.com/sonatype/docker-nexus3#persistent-data



      That said, if you really do need to do this it can be done via the scripting/provisioning API's:



      https://github.com/sonatype/docker-nexus3#persistent-data






      share|improve this answer

























        0












        0








        0







        The work directory should be on persistent storage, so you shouldn't need to recreate configuration on every startup.



        https://github.com/sonatype/docker-nexus3#persistent-data



        That said, if you really do need to do this it can be done via the scripting/provisioning API's:



        https://github.com/sonatype/docker-nexus3#persistent-data






        share|improve this answer













        The work directory should be on persistent storage, so you shouldn't need to recreate configuration on every startup.



        https://github.com/sonatype/docker-nexus3#persistent-data



        That said, if you really do need to do this it can be done via the scripting/provisioning API's:



        https://github.com/sonatype/docker-nexus3#persistent-data







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 5 '18 at 15:00









        rseddonrseddon

        3,54789




        3,54789



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53261766%2fcreating-a-repository-and-uploading-artifacts-to-a-nexus3-docker-container%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo