Skip to content

Commit

Permalink
Go source install
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <[email protected]>
  • Loading branch information
kpango committed Feb 7, 2024
1 parent 0203abb commit dcc8fe7
Show file tree
Hide file tree
Showing 19 changed files with 194 additions and 98 deletions.
11 changes: 3 additions & 8 deletions Makefile.d/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,9 @@ docker/name/agent-faiss:
.PHONY: docker/build/agent-faiss
## build agent-faiss image
docker/build/agent-faiss:
$(DOCKER) build \
$(DOCKER_OPTS) \
-f dockers/agent/core/faiss/Dockerfile \
-t $(ORG)/vald-agent-faiss:$(TAG) . \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \
--build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \
--build-arg MAINTAINER=$(MAINTAINER)
@make DOCKERFILE="$(ROOTDIR)/dockers/agent/core/faiss/Dockerfile" \
IMAGE=$(AGENT_IMAGE) \
docker/build/image

.PHONY: docker/name/agent-sidecar
docker/name/agent-sidecar:
Expand Down
7 changes: 4 additions & 3 deletions Makefile.d/functions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,17 @@ define go-build
echo $(PBGOS)
echo $(shell find $(ROOTDIR)/cmd/$1 -type f -name '*.go' -not -name '*_test.go' -not -name 'doc.go')
echo $(shell find $(ROOTDIR)/pkg/$1 -type f -name '*.go' -not -name '*_test.go' -not -name 'doc.go')
CGO_CXXFLAGS="-g -Ofast -march=native" \
CFLAGS="$(CFLAGS)" \
CXXFLAGS="$(CXXFLAGS)" \
CGO_ENABLED=$(CGO_ENABLED) \
CGO_CXXFLAGS="-g -Ofast -march=native" \
CGO_FFLAGS="-g -Ofast -march=native" \
CGO_LDFLAGS="-g -Ofast -march=native" \
CFLAGS="$(CFLAGS)" \
CXXFLAGS="$(CXXFLAGS)" \
GO111MODULE=on \
GOARCH=$(GOARCH) \
GOOS=$(GOOS) \
GOPRIVATE=$(GOPRIVATE) \
GO_VERSION=$(GO_VERSION) \
go build \
--ldflags "-w $2 \
-extldflags '-static $3' \
Expand Down
16 changes: 11 additions & 5 deletions dockers/agent/core/faiss/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
# limitations under the License.
#

ARG GO_VERSION=latest
# ARG DISTROLESS_IMAGE=gcr.io/distroless/static
# ARG DISTROLESS_IMAGE_TAG=nonroot
ARG MAINTAINER="vdaas.org vald team <[email protected]>"

FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang

FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder

ARG GO_VERSION
ARG TARGETARCH
ARG TARGETOS

Expand Down Expand Up @@ -55,8 +53,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=golang /usr/local/go $GOROOT
RUN mkdir -p "$GOPATH/src"
WORKDIR /opt
RUN set -x && cd "$(mktemp -d)" \
&& BIN_NAME="go" \
&& TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \
&& curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \
&& tar zxf "${TAR_NAME}" \
&& rm "${TAR_NAME}" \
&& mv ${BIN_NAME} ${GOROOT} \
&& ${BIN_NAME} version \
&& mkdir -p "${GOPATH}/src"

WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d
COPY Makefile.d .
Expand Down
16 changes: 11 additions & 5 deletions dockers/agent/core/ngt/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@
# limitations under the License.
#

ARG GO_VERSION=latest
ARG DISTROLESS_IMAGE=gcr.io/distroless/static
ARG DISTROLESS_IMAGE_TAG=nonroot
ARG MAINTAINER="vdaas.org vald team <[email protected]>"

FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang

FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder

ARG TARGETARCH
ARG TARGETOS
ARG GO_VERSION

ENV GO111MODULE on
ENV DEBIAN_FRONTEND noninteractive
Expand Down Expand Up @@ -57,8 +55,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=golang /usr/local/go $GOROOT
RUN mkdir -p "$GOPATH/src"
WORKDIR /opt
RUN set -x && cd "$(mktemp -d)" \
&& BIN_NAME="go" \
&& TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \
&& curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \
&& tar zxf "${TAR_NAME}" \
&& rm "${TAR_NAME}" \
&& mv ${BIN_NAME} ${GOROOT} \
&& ${BIN_NAME} version \
&& mkdir -p "${GOPATH}/src"

WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d
COPY Makefile.d .
Expand Down
16 changes: 11 additions & 5 deletions dockers/agent/sidecar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
# limitations under the License.
#

ARG GO_VERSION=latest
ARG DISTROLESS_IMAGE=gcr.io/distroless/static
ARG DISTROLESS_IMAGE_TAG=nonroot
ARG MAINTAINER="vdaas.org vald team <[email protected]>"

FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang

FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder

ARG GO_VERSION
ARG TARGETARCH
ARG TARGETOS

Expand All @@ -50,8 +48,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=golang /usr/local/go $GOROOT
RUN mkdir -p "$GOPATH/src"
WORKDIR /opt
RUN set -x && cd "$(mktemp -d)" \
&& BIN_NAME="go" \
&& TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \
&& curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \
&& tar zxf "${TAR_NAME}" \
&& rm "${TAR_NAME}" \
&& mv ${BIN_NAME} ${GOROOT} \
&& ${BIN_NAME} version \
&& mkdir -p "${GOPATH}/src"

WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d
COPY Makefile.d .
Expand Down
19 changes: 12 additions & 7 deletions dockers/ci/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
# limitations under the License.
#

ARG GO_VERSION=latest
ARG MAINTAINER="vdaas.org vald team <[email protected]>"

FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang

FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder
LABEL maintainer="${MAINTAINER}"

ARG GO_VERSION
ARG TARGETARCH
ARG TARGETOS

Expand All @@ -34,10 +32,6 @@ ENV GOROOT /opt/go
ENV GOPATH /go
ENV PATH ${PATH}:${GOROOT}/bin:${GOPATH}/bin:/usr/local/bin

COPY --from=golang /usr/local/go $GOROOT
RUN mkdir -p $GOPATH/src


RUN sysctl -w net.ipv6.conf.all.disable_ipv6=1 \
&& sysctl -w net.ipv6.conf.default.disable_ipv6=1 \
&& sysctl -w net.ipv6.conf.lo.disable_ipv6=1
Expand Down Expand Up @@ -68,6 +62,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt
RUN set -x && cd "$(mktemp -d)" \
&& BIN_NAME="go" \
&& TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \
&& curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \
&& tar zxf "${TAR_NAME}" \
&& rm "${TAR_NAME}" \
&& mv ${BIN_NAME} ${GOROOT} \
&& ${BIN_NAME} version \
&& mkdir -p "${GOPATH}/src"

WORKDIR ${GOPATH}/src/github.com/vdaas/vald

ENV ROOTDIR .
Expand Down
16 changes: 11 additions & 5 deletions dockers/discoverer/k8s/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
# limitations under the License.
#

ARG GO_VERSION=latest
ARG DISTROLESS_IMAGE=gcr.io/distroless/static
ARG DISTROLESS_IMAGE_TAG=nonroot
ARG MAINTAINER="vdaas.org vald team <[email protected]>"

FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang

FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder

ARG GO_VERSION
ARG TARGETARCH
ARG TARGETOS

Expand All @@ -50,8 +48,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=golang /usr/local/go $GOROOT
RUN mkdir -p "$GOPATH/src"
WORKDIR /opt
RUN set -x && cd "$(mktemp -d)" \
&& BIN_NAME="go" \
&& TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \
&& curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \
&& tar zxf "${TAR_NAME}" \
&& rm "${TAR_NAME}" \
&& mv ${BIN_NAME} ${GOROOT} \
&& ${BIN_NAME} version \
&& mkdir -p "${GOPATH}/src"

WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d
COPY Makefile.d .
Expand Down
14 changes: 10 additions & 4 deletions dockers/gateway/filter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static
ARG DISTROLESS_IMAGE_TAG=nonroot
ARG MAINTAINER="vdaas.org vald team <[email protected]>"

FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang

FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder

ARG TARGETARCH
Expand Down Expand Up @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=golang /usr/local/go $GOROOT
RUN mkdir -p "$GOPATH/src"
WORKDIR /opt
RUN set -x && cd "$(mktemp -d)" \
&& BIN_NAME="go" \
&& TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \
&& curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \
&& tar zxf "${TAR_NAME}" \
&& rm "${TAR_NAME}" \
&& mv ${BIN_NAME} ${GOROOT} \
&& ${BIN_NAME} version \
&& mkdir -p "${GOPATH}/src"

WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d
COPY Makefile.d .
Expand Down
16 changes: 11 additions & 5 deletions dockers/gateway/lb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
# limitations under the License.
#

ARG GO_VERSION=latest
ARG DISTROLESS_IMAGE=gcr.io/distroless/static
ARG DISTROLESS_IMAGE_TAG=nonroot
ARG MAINTAINER="vdaas.org vald team <[email protected]>"

FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang

FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder

ARG GO_VERSION
ARG TARGETARCH
ARG TARGETOS

Expand All @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=golang /usr/local/go $GOROOT
RUN mkdir -p "$GOPATH/src"
WORKDIR /opt
RUN set -x && cd "$(mktemp -d)" \
&& BIN_NAME="go" \
&& TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \
&& curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \
&& tar zxf "${TAR_NAME}" \
&& rm "${TAR_NAME}" \
&& mv ${BIN_NAME} ${GOROOT} \
&& ${BIN_NAME} version \
&& mkdir -p "${GOPATH}/src"

WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d
COPY Makefile.d .
Expand Down
16 changes: 11 additions & 5 deletions dockers/gateway/mirror/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
ARG GO_VERSION=latest
ARG DISTROLESS_IMAGE=gcr.io/distroless/static
ARG DISTROLESS_IMAGE_TAG=nonroot
ARG MAINTAINER="vdaas.org vald team <[email protected]>"

FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang

FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder

ARG GO_VERSION
ARG TARGETARCH
ARG TARGETOS

Expand All @@ -48,8 +46,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=golang /usr/local/go $GOROOT
RUN mkdir -p "$GOPATH/src"
WORKDIR /opt
RUN set -x && cd "$(mktemp -d)" \
&& BIN_NAME="go" \
&& TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \
&& curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \
&& tar zxf "${TAR_NAME}" \
&& rm "${TAR_NAME}" \
&& mv ${BIN_NAME} ${GOROOT} \
&& ${BIN_NAME} version \
&& mkdir -p "${GOPATH}/src"

WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}

Expand Down
16 changes: 11 additions & 5 deletions dockers/index/job/correction/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
# limitations under the License.
#

ARG GO_VERSION=latest
ARG DISTROLESS_IMAGE=gcr.io/distroless/static
ARG DISTROLESS_IMAGE_TAG=nonroot
ARG MAINTAINER="vdaas.org vald team <[email protected]>"

FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang

FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder

ARG GO_VERSION
ARG TARGETARCH
ARG TARGETOS

Expand All @@ -49,8 +47,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY --from=golang /usr/local/go $GOROOT
RUN mkdir -p "$GOPATH/src"
WORKDIR /opt
RUN set -x && cd "$(mktemp -d)" \
&& BIN_NAME="go" \
&& TAR_NAME="${BIN_NAME}${GO_VERSION}.${TARGETOS}-${TARGETARCH}.tar.gz" \
&& curl -fsSLO "https://go.dev/dl/${TAR_NAME}" \
&& tar zxf "${TAR_NAME}" \
&& rm "${TAR_NAME}" \
&& mv ${BIN_NAME} ${GOROOT} \
&& ${BIN_NAME} version \
&& mkdir -p "${GOPATH}/src"

WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d
COPY Makefile.d .
Expand Down
Loading

0 comments on commit dcc8fe7

Please sign in to comment.