跳转至

Docker部署ArtifactoryPro

准备镜像

拉取官方镜像:

docker pull releases-docker.jfrog.io/jfrog/artifactory-pro:7.55.6
# docker pull docker.bintray.io/jfrog/artifactory⁠-⁠pro:7.55.6
# 也可以选择 latest 标签

安装

启动原版容器

准备一个持久化路径

export JFROG_HOME=/data/sdb

创建配置文件目录

mkdir -p $JFROG_HOME/artifactory/var/etc/

创建一个配置文件

cd $JFROG_HOME/artifactory/var/etc/

touch ./system.yaml

更改权限

chown -R 1030:1030 $JFROG_HOME/artifactory/var

运行容器

# for debug
docker run \
 --name artifactory \
 -v $JFROG_HOME/artifactory/var/:/var/opt/jfrog/artifactory \
 -it \
 --rm \
 -p 18081:8081 \
 -p 18082:8082 \
 harbor.local.liaosirui.com:5000/3rdparty/releases-docker.jfrog.io/jfrog/artifactory-pro:7.55.6

等待启动完成

hack

参考:https://github.com/Lama3L9R/ArtifactoryKeygen

配置反向代理

从 IP 地址访问 artifactory

http://192.168.1.99:18081/artifactory/webapp/#/home

默认登录用户名 admin / password

新建一个配置文件存放

export JFROG_HOME=/data/sda/sda4

mkdir -p $JFROG_HOME/nginx/cert

mkdir -p $JFROG_HOME/nginx/conf

生成一对自签证书

cd $JFROG_HOME/nginx/cert

openssl req -x509 -nodes -days 700 -newkey rsa:2048 -keyout artifactory-tls.key -out artifactory-ca.crt -subj "/CN=artifactory.local.liaosirui.com"

chmod 777 artifactory-*

在 Artifactory 生成配置文件

拷贝 nginx 配置文件

###########################################################
## this configuration was generated by JFrog Artifactory ##
###########################################################

## add ssl entries when https has been set in config
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_certificate      /cert/artifactory-ca.crt;
ssl_certificate_key  /cert/artifactory-tls.key;
ssl_session_cache shared:SSL:1m;
ssl_prefer_server_ciphers   on;
## server configuration
server {
    listen 9443 ssl;
    listen 9080 ;

    server_name artifactory.local.liaosirui.com;
    if ($http_x_forwarded_proto = '') {
        set $http_x_forwarded_proto  $scheme;
    }
    ## Application specific logs
    ## access_log /var/log/nginx/artifactory.local.liaosirui.com-access.log timing;
    ## error_log /var/log/nginx/artifactory.local.liaosirui.com-error.log;
    rewrite ^/$ /artifactory/webapp/ redirect;
    rewrite ^/artifactory/?(/webapp)?$ /artifactory/webapp/ redirect;
    rewrite ^/(v2)/(.*) /artifactory/$1/$2;
    chunked_transfer_encoding on;
    client_max_body_size 0;
    location /artifactory/ {
    proxy_read_timeout  2400s;
    proxy_pass_header   Server;
    proxy_cookie_path   ~*^/.* /;
    if ( $request_uri ~ ^/artifactory/(.*)$ ) {
        proxy_pass          http://artifactory:8081/artifactory/$1;
    }
    proxy_pass          http://artifactory:8081/artifactory/;
    proxy_set_header    X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host:$server_port/artifactory;
    proxy_set_header    X-Forwarded-Port  $server_port;
    proxy_set_header    X-Forwarded-Proto $http_x_forwarded_proto;
    proxy_set_header    Host              $http_host;
    proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
    }
}

创建配置文件

vim artifactory.conf
# 写入自动生成的配置文件

运行如下

docker run --name artifactory-pro-nginx \
    -p 9080:9080 \
    -p 9443:9443 \
    -itd \
    --restart=always \
    -e SKIP_AUTO_UPDATE_CONFIG=true \
    --link artifactory:artifactory \
    -v $JFROG_HOME/nginx/conf:/var/opt/jfrog/nginx/conf.d/  \
    -v $JFROG_HOME/nginx/cert:/cert  \
    --name artifactory-proxy \
    releases-docker.jfrog.io/jfrog/nginx-artifactory-pro:latest