Sign inSign up

clockdiff/build-go

By clockdiff

•Updated over 5 years ago

Image
0

40

clockdiff/build-go repository overview

⁠S2I

⁠Dockerfile

# build-go
FROM centos:7
MAINTAINER clockdiff
LABEL io.k8s.description="Includes and is limited to builds of the Golang environment" \
io.openshift.tags="builder,go1.13.3" \
Author="Clockdiff" \
Version="1.0" \
MavenVersion="go-1.13.3" \
io.openshift.s2i.scripts-url="image:///usr/libexec/s2i"

ENV LANG en_US.UTF-8
ENV TZ Asia/Shanghai
ENV GOROOT=/usr/local/go
ENV GOBIN=$GOROOT/bin
ENV GOPKG=$GOROOT/pkg/tool/linux_amd64
ENV GOARCH=amd64
ENV GOOS=linux
ENV PATH=$PATH:$GOBIN:$GOPKG:$GOPATH/bin
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct⁠

ADD go1.13.3.linux-amd64.tar.gz /usr/local

COPY docker.repo /etc/yum.repos.d/docker.repo
COPY ./s2i/bin/ /usr/libexec/s2i

RUN mkdir -p /data/apps/src ;\
useradd -s /sbin/nologin -b /data/apps/ -M -u 1001 -g 0 -c "Baison springcloud applications run user" baison ;\
yum install -y docker-ce-cli iproute telnet net-tools;\
yum clean all ;\
rm -rf /var/cache/yum/*
RUN chown -R 1001:0 /data/apps/ ;\
chmod g+w /data/apps/

USER 1001
CMD /usr/libexec/s2i/usage

⁠docker.repo

[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=http://mirrors.ustc.edu.cn/docker-ce/linux/centos/7/x86_64/stable⁠
enabled=1
gpgcheck=0

⁠assemble

#!/bin/bash -e
#
# S2I assemble script for the 'build-go' image.
# The 'assemble' script builds your application source so that it is ready to run.
#
# For more information refer to the documentation:
# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md⁠

echo "---> Installing application source"
cp -Rf /tmp/src/. /data/apps/src
cd /data/apps/src
gofilename=$(find . -name .go)
goname=${gofilename##
/}
echo "------#### build ${goname} ####------"
go build ${goname}
goexecutablename=${goname%.*}
echo "------####可执行文件为: ${goexecutablename}####------"
chmod a+x ${goexecutablename}
chmod 777 /data/apps/src

⁠run

#!/bin/bash -e
#
# S2I run script for the 'build-go' image.
# The run script executes the server that runs your application.
#
# For more information see the documentation:
# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md⁠
#

cd /data/apps/src/
gofilename=$(find . -name .go)
goname=${gofilename##
/}
goexecutablename=${goname%.*}
echo "------####可执行文件为: ${goexecutablename}####------"
./${goexecutablename}

Tag summary

Content type

Image

Digest

Size

238.1 MB

Last updated

over 5 years ago

docker pull clockdiff/build-go:v1