# 将下载的cfssl移动到/usr/local/bin/目录下,并附加执行权限

cp  -a cfssl-certinfo   /usr/local/bin/cfssl-certinfo && chmod +x  /usr/local/bin/cfssl-certinfo 

cp  cfssljson    /usr/local/bin/cfssljson && chmod +x  /usr/local/bin/cfssljson 

cp  cfssl   /usr/local/bin/cfssl && chmod +x /usr/local/bin/cfssl 


/usr/bin/cfssl version


#编译

wget https://github.com/cloudflare/cfssl/archive/refs/tags/v1.5.0.zip

unzip  v1.5.0.zip

-设置代理

go env -w GO111MODULE=on

go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/

-rice 

cd cfssl-1.5.0

go get github.com/GeertJohan/go.rice/rice 

rice embed-go -i=./cli/serve 

静态编译cfssl

CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o bin/cfssl cmd/cfssl/cfssl.go

CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o bin/cfssljson cmd/cfssljson/cfssljson.go 

CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o bin/cfssl-certinfo cmd/cfssl-certinfo/cfssl-certinfo.go

查看静态编译程序文件

[root@192-168-111-193 cfssl-1.2.0]# file bin/*

bin/cfssl:          ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped

bin/cfssl-certinfo: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped

bin/cfssljson:      ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped

[root@192-168-111-193 cfssl-1.2.0]# ./bin/cfssl version

Version: dev

Runtime: go1.13




Dockerfile:

FROM arm64v8/ubuntu
ARG CFSSL_REV=b94e044
ENV \
  GOPATH=/root/go

ENV DEBIAN_FRONTEND=non-interactive 

RUN \
  apt-get update && \
  apt-get install -y wget vim net-tools curl git cron axel zip unzip && \
  apt-get -y install golang-go git cmake build-essential autoconf automake libtool  gcc make gdb && \
  mkdir /root/go
  
RUN \
  git clone https://github.com/cloudflare/cfssl.git  /root/go/src/github.com/cloudflare/cfssl && \
  cd /root/go/src/github.com/cloudflare/cfssl && \
  git checkout $CFSSL_TAG && \
  make GOPATH=/root/go -j$(nproc)
RUN mkdir /input /output
FROM scratch
COPY \
  --from=0 \
    /root/go/src/github.com/cloudflare/cfssl/bin/cfssl           \
    /root/go/src/github.com/cloudflare/cfssl/bin/cfssl-bundle    \
    /root/go/src/github.com/cloudflare/cfssl/bin/cfssl-certinfo  \
    /root/go/src/github.com/cloudflare/cfssl/bin/cfssl-newkey    \
    /root/go/src/github.com/cloudflare/cfssl/bin/cfssl-scan      \
    /root/go/src/github.com/cloudflare/cfssl/bin/cfssljson       \
    /root/go/src/github.com/cloudflare/cfssl/bin/mkbundle        \
    /root/go/src/github.com/cloudflare/cfssl/bin/multirootca     \
  /
COPY --from=0 /input/ /output/ /
CMD ["/cfssl"]


cd /data/docker/tools/Dockerfile/cfssl

docker build -t cfssl  .

docker tag cfssl:latest hub.htmltoo.com:5000/http:cfssl

docker push hub.htmltoo.com:5000/http:cfssl



docker cp containerID:container_path host_path # 从容器拷贝复制到主机


签名:这个人很懒,什么也没有留下!
最新回复 (0)
返回