mirror of
https://gitee.com/kennylee/docker.git
synced 2024-11-29 18:38:34 +08:00
新增golang镜像容器
This commit is contained in:
parent
65b9fe2aa7
commit
4e9d0a52a4
2
debian/jessie/Dockerfile
vendored
2
debian/jessie/Dockerfile
vendored
@ -13,7 +13,7 @@ RUN echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib\n\
|
|||||||
deb http://ftp.cn.debian.org/debian jessie main" > /etc/apt/sources.list
|
deb http://ftp.cn.debian.org/debian jessie main" > /etc/apt/sources.list
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y curl git unzip vim wget && \
|
apt-get install -y curl git unzip vim wget iputils-ping && \
|
||||||
apt-get install -y locales kde-l10n-zhcn && \
|
apt-get install -y locales kde-l10n-zhcn && \
|
||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
67
golang/1.8/Dockerfile
Normal file
67
golang/1.8/Dockerfile
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
FROM buildpack-deps:jessie-scm
|
||||||
|
|
||||||
|
RUN echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib\n\
|
||||||
|
deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib\n\
|
||||||
|
deb http://mirrors.163.com/debian/ jessie-backports main non-free contrib\n\
|
||||||
|
deb-src http://mirrors.163.com/debian/ jessie main non-free contrib\n\
|
||||||
|
deb-src http://mirrors.163.com/debian/ jessie-updates main non-free contrib\n\
|
||||||
|
deb-src http://mirrors.163.com/debian/ jessie-backports main non-free contrib\n\
|
||||||
|
deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib\n\
|
||||||
|
deb-src http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib\n\
|
||||||
|
deb http://ftp.cn.debian.org/debian jessie main" > /etc/apt/sources.list
|
||||||
|
|
||||||
|
# gcc for cgo
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
g++ \
|
||||||
|
gcc \
|
||||||
|
libc6-dev \
|
||||||
|
make \
|
||||||
|
pkg-config \
|
||||||
|
&& apt-get install -y curl git unzip vim iputils-ping wget \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
ENV GOLANG_VERSION 1.8.3
|
||||||
|
|
||||||
|
RUN set -eux; \
|
||||||
|
\
|
||||||
|
# this "case" statement is generated via "update.sh"
|
||||||
|
dpkgArch="$(dpkg --print-architecture)"; \
|
||||||
|
case "${dpkgArch##*-}" in \
|
||||||
|
amd64) goRelArch='linux-amd64'; goRelSha256='1862f4c3d3907e59b04a757cfda0ea7aa9ef39274af99a784f5be843c80c6772' ;; \
|
||||||
|
armhf) goRelArch='linux-armv6l'; goRelSha256='3c30a3e24736ca776fc6314e5092fb8584bd3a4a2c2fa7307ae779ba2735e668' ;; \
|
||||||
|
i386) goRelArch='linux-386'; goRelSha256='ff4895eb68fb1daaec41c540602e8bb4c1e8bb2f0e7017367171913fc9995ed2' ;; \
|
||||||
|
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='e5fb00adfc7291e657f1f3d31c09e74890b5328e6f991a3f395ca72a8c4dc0b3' ;; \
|
||||||
|
s390x) goRelArch='linux-s390x'; goRelSha256='e2ec3e7c293701b57ca1f32b37977ac9968f57b3df034f2cc2d531e80671e6c8' ;; \
|
||||||
|
*) goRelArch='src'; goRelSha256='5f5dea2447e7dcfdc50fa6b94c512e58bfba5673c039259fd843f68829d99fa6'; \
|
||||||
|
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"; \
|
||||||
|
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
|
||||||
|
tar -C /usr/local -xzf go.tgz; \
|
||||||
|
rm go.tgz; \
|
||||||
|
\
|
||||||
|
if [ "$goRelArch" = 'src' ]; then \
|
||||||
|
echo >&2; \
|
||||||
|
echo >&2 'error: UNIMPLEMENTED'; \
|
||||||
|
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
|
||||||
|
echo >&2; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
\
|
||||||
|
export PATH="/usr/local/go/bin:$PATH"; \
|
||||||
|
go version
|
||||||
|
|
||||||
|
ENV GOPATH /go
|
||||||
|
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
|
||||||
|
RUN ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
|
||||||
|
echo $TZ > /etc/timezone && \
|
||||||
|
dpkg-reconfigure --frontend noninteractive tzdata
|
||||||
|
|
||||||
|
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
|
||||||
|
WORKDIR $GOPATH
|
||||||
|
|
||||||
|
COPY go-wrapper /usr/local/bin/
|
87
golang/1.8/go-wrapper
Normal file
87
golang/1.8/go-wrapper
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
base="$(basename "$0")"
|
||||||
|
cat <<EOUSAGE
|
||||||
|
usage: $base command [args]
|
||||||
|
This script assumes that is is run from the root of your Go package (for
|
||||||
|
example, "/go/src/app" if your GOPATH is set to "/go").
|
||||||
|
In Go 1.4, a feature was introduced to supply the canonical "import path" for a
|
||||||
|
given package in a comment attached to a package statement
|
||||||
|
(https://golang.org/s/go14customimport).
|
||||||
|
This script allows us to take a generic directory of Go source files such as
|
||||||
|
"/go/src/app" and determine that the canonical "import path" of where that code
|
||||||
|
expects to live and reference itself is "github.com/jsmith/my-cool-app". It
|
||||||
|
will then ensure that "/go/src/github.com/jsmith/my-cool-app" is a symlink to
|
||||||
|
"/go/src/app", which allows us to build and run it under the proper package
|
||||||
|
name.
|
||||||
|
For compatibility with versions of Go older than 1.4, the "import path" may also
|
||||||
|
be placed in a file named ".godir".
|
||||||
|
Available Commands:
|
||||||
|
$base download
|
||||||
|
$base download -u
|
||||||
|
(equivalent to "go get -d [args] [godir]")
|
||||||
|
$base install
|
||||||
|
$base install -race
|
||||||
|
(equivalent to "go install [args] [godir]")
|
||||||
|
$base run
|
||||||
|
$base run -app -specific -arguments
|
||||||
|
(assumes "GOPATH/bin" is in "PATH")
|
||||||
|
EOUSAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
# make sure there is a subcommand specified
|
||||||
|
if [ "$#" -eq 0 ]; then
|
||||||
|
usage >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# "shift" so that "$@" becomes the remaining arguments and can be passed along to other "go" subcommands easily
|
||||||
|
cmd="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
goDir="$(go list -e -f '{{.ImportComment}}' 2>/dev/null || true)"
|
||||||
|
|
||||||
|
if [ -z "$goDir" -a -s .godir ]; then
|
||||||
|
goDir="$(cat .godir)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
dir="$(pwd -P)"
|
||||||
|
if [ "$goDir" ]; then
|
||||||
|
goPath="${GOPATH%%:*}" # this just grabs the first path listed in GOPATH, if there are multiple (which is the detection logic "go get" itself uses, too)
|
||||||
|
goDirPath="$goPath/src/$goDir"
|
||||||
|
mkdir -p "$(dirname "$goDirPath")"
|
||||||
|
if [ ! -e "$goDirPath" ]; then
|
||||||
|
ln -sfv "$dir" "$goDirPath"
|
||||||
|
elif [ ! -L "$goDirPath" ]; then
|
||||||
|
echo >&2 "error: $goDirPath already exists but is unexpectedly not a symlink!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
goBin="$goPath/bin/$(basename "$goDir")"
|
||||||
|
else
|
||||||
|
goBin="$(basename "$dir")" # likely "app"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$cmd" in
|
||||||
|
download)
|
||||||
|
set -- go get -v -d "$@"
|
||||||
|
if [ "$goDir" ]; then set -- "$@" "$goDir"; fi
|
||||||
|
set -x; exec "$@"
|
||||||
|
;;
|
||||||
|
|
||||||
|
install)
|
||||||
|
set -- go install -v "$@"
|
||||||
|
if [ "$goDir" ]; then set -- "$@" "$goDir"; fi
|
||||||
|
set -x; exec "$@"
|
||||||
|
;;
|
||||||
|
|
||||||
|
run)
|
||||||
|
set -x; exec "$goBin" "$@"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo >&2 'error: unknown command:' "$cmd"
|
||||||
|
usage >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
@ -13,7 +13,7 @@ RUN sed -i 's/archive.ubuntu.com/mirrors.163.com/g' /etc/apt/sources.list
|
|||||||
RUN \
|
RUN \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get -y upgrade && \
|
apt-get -y upgrade && \
|
||||||
apt-get install -y curl git unzip vim wget && \
|
apt-get install -y curl git unzip vim wget iputils-ping && \
|
||||||
apt-get install -y language-pack-zh-hans && \
|
apt-get install -y language-pack-zh-hans && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ RUN sed -i 's/archive.ubuntu.com/mirrors.163.com/g' /etc/apt/sources.list
|
|||||||
RUN \
|
RUN \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
apt-get -y upgrade && \
|
apt-get -y upgrade && \
|
||||||
apt-get install -y curl git unzip vim wget && \
|
apt-get install -y curl git unzip vim wget iputils-ping && \
|
||||||
apt-get install -y language-pack-zh-hans && \
|
apt-get install -y language-pack-zh-hans && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user