目的
制作一个自带jfrog命令的docker image。
Dockerfile
From debian:latest
ENV http_proxy http://*** https_proxy http://***
#base tools start
RUN apt-get update && apt-get install -y wget curl vim
COPY jfrog /var/fpwork/jfrog/
COPY jfrog-cli.conf /root/.jfrog/
#base tools end
ENV PATH=/var/fpwork/jfrog:$PATH
Dockerfile同层级目录下的文件
1. jfrog
使用如下脚本下载jfrog
#!/bin/bash
CLI_OS="na"
CLI_UNAME="na"
if $(echo "${OSTYPE}" | grep -q msys); then
CLI_OS="windows"
URL="https://api.bintray.com/content/jfrog/jfrog-cli-go/\$latest/jfrog-cli-windows-amd64/jfrog.exe?bt_package=jfrog-cli-windows-amd64"
FILE_NAME="jfrog.exe"
elif $(echo "${OSTYPE}" | grep -q darwin); then
CLI_OS="mac"
URL="https://api.bintray.com/content/jfrog/jfrog-cli-go/\$latest/jfrog-cli-mac-386/jfrog?bt_package=jfrog-cli-mac-386"
FILE_NAME="jfrog"
else
CLI_OS="linux"
if $(uname -m | grep -q 64); then
CLI_UNAME="64"
URL="https://api.bintray.com/content/jfrog/jfrog-cli-go/\$latest/jfrog-cli-linux-amd64/jfrog?bt_package=jfrog-cli-linux-amd64"
FILE_NAME="jfrog"
else
CLI_UNAME="32"
URL="https://api.bintray.com/content/jfrog/jfrog-cli-go/\$latest/jfrog-cli-linux-386/jfrog?bt_package=jfrog-cli-linux-386"
FILE_NAME="jfrog"
fi
fi
curl -XGET "$URL" -L -k > $FILE_NAME
chmod u+x $FILE_NAME
2. jfrog-cli.conf
配置如下
{
"artifactory": [
{
"url": "https://*********:443/artifactory/",
"user": "your_name",
"apiKey": "*****************************************",
"serverId": "Default-Server",
"isDefault": true
}
],
"Version": "1"
}
测试
jfrog rt s --apikey=***** --url=https://******:443/artifactory project/dir1/dir2/
Tips
jfrog-cli.conf
没有的话第一次执行jfrog命令会有交互界面要求进行配置,默认保存在~/.jfrog/ 下面,因为我是root账户,所以COPY到了/root/.jfrog/ 下面。
dockerfile 中可以通过ENV JFROG_CLI_HOME=***
来改变配置目录。