标签:ccf golang save generated container freebsd path default 官方
buildpack-deps 是docker hub 官方提供的一个构建类似heroku stack 镜像的工具包,如果自己看的话,好多docker 官方的基础镜像都基于此基础镜像
进行构建的,buildpack-deps 已经提供了好多内置好多依赖库,可以简化我们的镜像部署,同时官方也提供了debian以及ubuntu 等的镜像,很值得使用
FROM buildpack-deps:buster-scm
?
# gcc for cgo
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
gcc \
libc6-dev \
make \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
?
ENV PATH /usr/local/go/bin:$PATH
?
ENV GOLANG_VERSION 1.14.6
?
RUN set -eux; \
\
# this "case" statement is generated via "update.sh"
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) goRelArch=‘linux-amd64‘; goRelSha256=‘5c566ddc2e0bcfc25c26a5dc44a440fcc0177f7350c1f01952b34d5989a0d287‘ ;; \
armhf) goRelArch=‘linux-armv6l‘; goRelSha256=‘cab39cc0fdf9731476a339af9d7bcd8fc661bfa323abb1ce9d1633fb31daeb07‘ ;; \
arm64) goRelArch=‘linux-arm64‘; goRelSha256=‘291bccfd7d7f1915599bbcc90e49d9fccfcb0004b7c62a2f5cdf0f96a09d6a3e‘ ;; \
i386) goRelArch=‘linux-386‘; goRelSha256=‘17b2c4e26bd3a82a0a44499ae2d36e3f2155d0fe2f6b9a14ac6b7c5afac3ca6a‘ ;; \
ppc64el) goRelArch=‘linux-ppc64le‘; goRelSha256=‘8eb4c84e7b6aa9edb966c467dd6764d131a57d27afbd87cc8f6d10535df9e898‘ ;; \
s390x) goRelArch=‘linux-s390x‘; goRelSha256=‘cb1f2d001ce15e51f7c4bd43f15045ea23d49268010bb981110242a532138749‘ ;; \
*) goRelArch=‘src‘; goRelSha256=‘73fc9d781815d411928eccb92bf20d5b4264797be69410eac854babe44c94c09‘; \
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \
esac; \
\
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
wget -O go.tgz "$url" --progress=dot:giga; \
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
\
# https://github.com/golang/go/issues/38536#issuecomment-616897960
if [ "$goRelArch" = ‘src‘ ]; then \
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends golang-go; \
\
goEnv="$(go env | sed -rn -e ‘/^GO(OS|ARCH|ARM|386)=/s//export \0/p‘)"; \
eval "$goEnv"; \
[ -n "$GOOS" ]; \
[ -n "$GOARCH" ]; \
( \
cd /usr/local/go/src; \
./make.bash; \
); \
\
apt-mark auto ‘.*‘ > /dev/null; \
apt-mark manual $savedAptMark > /dev/null; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*; \
\
# pre-compile the standard library, just like the official binary release tarballs do
go install std; \
# go install: -race is only supported on linux/amd64, linux/ppc64le, linux/arm64, freebsd/amd64, netbsd/amd64, darwin/amd64 and windows/amd64
# go install -race std; \
\
# remove a few intermediate / bootstrapping files the official binary release tarballs do not contain
rm -rf \
/usr/local/go/pkg/*/cmd \
/usr/local/go/pkg/bootstrap \
/usr/local/go/pkg/obj \
/usr/local/go/pkg/tool/*/api \
/usr/local/go/pkg/tool/*/go_bootstrap \
/usr/local/go/src/cmd/dist/dist \
; \
fi; \
\
go version
?
ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
WORKDIR $GOPATH
cncf 的buildpacks 也是一个很不错的选择,目前还在孵化中, 同时cloudfoundry 基于buildpacks模式也已经提供了好多语言的支持
https://github.com/docker-library/buildpack-deps
https://hub.docker.com/_/buildpack-deps/
https://github.com/heroku/stack-images/
https://github.com/buildpacks
标签:ccf golang save generated container freebsd path default 官方
原文地址:https://www.cnblogs.com/rongfengliang/p/13353793.html