简体   繁体   English

创建存储库并将工件上传到Nexus3 Docker容器

[英]Creating a repository and uploading artifacts to a Nexus3 docker container

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. 首先,我想知道在容器启动后如何在Nexus3容器上创建新存储库。 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. 基本上,两个cURL请求必须在就绪后发送到容器。 The cURL requests are as follows: cURL请求如下:

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) (当容器准备好后,当我通过邮递员之类的应用程序手动发送它们时,上面的curl请求就起作用了。我只是不确定如何让docker为我做这件事)

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? nexus3映像上是否有一个我可以执行COPY命令并将所需工件复制到存储库的位置?

Below is part of my docker-compose.yml 以下是我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 :) 感谢您提供的任何帮助:)

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 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: 也就是说,如果您确实需要执行此操作,则可以通过脚本/配置API来完成:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM