设置PATH变量并在Dockerfile中查找环境
我已经编写了一个Dockerfile来创建安装了Golang的容器。我有一个goss测试运行go version命令,但是测试失败了,因为path变量(在Dockerfile中)——出于某种原因——没有保持设置 我还尝试从Dockerfile内部为go寻找.env,但这似乎也不起作用 Dockerfile设置PATH变量并在Dockerfile中查找环境,docker,go,path,dockerfile,Docker,Go,Path,Dockerfile,我已经编写了一个Dockerfile来创建安装了Golang的容器。我有一个goss测试运行go version命令,但是测试失败了,因为path变量(在Dockerfile中)——出于某种原因——没有保持设置 我还尝试从Dockerfile内部为go寻找.env,但这似乎也不起作用 Dockerfile ENV GIMME_VERSION "v1.4.0" ENV GO_VERSION "1.4" ENV JENKINS_HOME "/opt/jenkins" ENV PATH="~/bin:
ENV GIMME_VERSION "v1.4.0"
ENV GO_VERSION "1.4"
ENV JENKINS_HOME "/opt/jenkins"
ENV PATH="~/bin:${PATH}"
ENV PATH=“/opt/jenkins/.gimme/versions/go1.4.linux.amd64/bin:${PATH}“
ENV GOROOT="/opt/jenkins/.gimme/versions/go${GO_VERSION}.linux.amd64"
USER root
RUN yum -y install git && \
yum -y clean all && \
rm -rf /var/cache/yum
WORKDIR $JENKINS_HOME
USER jenkins
RUN mkdir ~/bin && \
curl -sL -o ~/bin/gimme https://raw.githubusercontent.com/travis-
ci/gimme/${GIMME_VERSION}/gimme && \
chmod +x ~/bin/gimme && \
gimme ${GO_VERSION}
USER root
RUN source /opt/jenkins/.gimme/envs/go${GO_VERSION}.linux.amd64.env
Goss Yaml
file:
/opt/jenkins/.gimme:
exists: true
filetype: directory
/opt/jenkins/.gimme/envs/go1.4.env:
exists: true
filetype: file
/opt/jenkins/.gimme/versions/go1.4.linux.amd64:
exists: true
filetype: directory
/opt/jenkins/.gimme/versions/go1.4.linux.amd64/bin/go:
exists: true
filetype: file
/opt/jenkins/.gimme/versions/go1.4.linux.amd64/pkg:
exists: true
filetype: directory
/opt/jenkins/.gimme/versions/go1.4.linux.amd64/src:
exists: true
filetype: directory
/opt/jenkins/bin/gimme:
filetype: file
exists: true
mode: '0755'
command:
'gimme version':
exit-status: 0
'go version':
exit-status: 0
乍一看不是很清楚,但是您在
PATH
周围的双引号不是很好的unicode字符。您应该用通常的“
”代替它们,而不是”
(Unicode UTF8码点U+201C
)
演示:不一样:
$ od -c <<< \"
0000000 " \n
0000002
$ od -c <<< \“
0000000 342 200 234 \n
0000004
$od-c乍一看不是很清楚,但是你在路径
周围的双引号不是很好的unicode字符。你应该用通常的“
”代替它们,而不是”
(unicode UTF8码点U+201C
)
演示:不一样:
$ od -c <<< \"
0000000 " \n
0000002
$ od -c <<< \“
0000000 342 200 234 \n
0000004
$od-c