-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: vankichi <[email protected]>
- Loading branch information
Showing
2 changed files
with
18 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,15 @@ | |
# 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 UPX_OPTIONS=-9 | ||
ARG MAINTAINER="vdaas.org vald team <[email protected]>" | ||
|
||
FROM golang:${GO_VERSION} AS golang | ||
|
||
FROM ubuntu:devel AS builder | ||
|
||
ARG UPX_OPTIONS | ||
|
@@ -47,17 +50,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ | |
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir -p ${GOPATH}/src | ||
|
||
COPY --from=golang /usr/local/go $GOROOT | ||
RUN mkdir -p "$GOPATH/src" | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} | ||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d | ||
COPY Makefile.d . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} | ||
COPY Makefile . | ||
COPY .git . | ||
COPY go.mod . | ||
COPY go.sum . | ||
|
||
RUN go mod download | ||
RUN make go/download | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/internal | ||
COPY internal . | ||
|
@@ -74,22 +79,15 @@ COPY cmd/${PKG} . | |
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions | ||
COPY versions . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d | ||
COPY Makefile.d . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} | ||
COPY Makefile . | ||
|
||
COPY .git . | ||
|
||
RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ | ||
&& upx ${UPX_OPTIONS} -o "/usr/bin/${APP_NAME}" "cmd/${PKG}/${APP_NAME}" | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} | ||
RUN cp sample.yaml /tmp/config.yaml | ||
|
||
FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} | ||
LABEL maintainer "Vald team <[email protected]>" | ||
LABEL maintainer="${MAINTAINER}" | ||
ENV APP_NAME job | ||
|
||
COPY --from=builder /usr/lib/x86_64-linux-gnu/libaec* /usr/lib/x86_64-linux-gnu/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ ARG DISTROLESS_IMAGE_TAG=nonroot | |
ARG UPX_OPTIONS=-9 | ||
ARG MAINTAINER="vdaas.org vald team <[email protected]>" | ||
|
||
FROM golang:${GO_VERSION} AS golang | ||
|
||
FROM ubuntu:devel AS builder | ||
|
||
ENV GO111MODULE on | ||
|
@@ -50,8 +52,12 @@ RUN mkdir -p ${GOPATH}/src | |
COPY --from=golang /usr/local/go $GOROOT | ||
RUN mkdir -p "$GOPATH/src" | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} | ||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d | ||
COPY Makefile.d . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} | ||
COPY Makefile . | ||
COPY .git . | ||
COPY go.mod . | ||
COPY go.sum . | ||
|
||
|
@@ -72,22 +78,15 @@ COPY cmd/${PKG} . | |
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/versions | ||
COPY versions . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/Makefile.d | ||
COPY Makefile.d . | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} | ||
COPY Makefile . | ||
|
||
COPY .git . | ||
|
||
RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ | ||
&& upx ${UPX_OPTIONS} -o "/usr/bin/${APP_NAME}" "cmd/${PKG}/${APP_NAME}" | ||
|
||
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} | ||
RUN cp sample.yaml /tmp/config.yaml | ||
|
||
FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} | ||
LABEL maintainer "Vald team <[email protected]>" | ||
LABEL maintainer="${MAINTAINER}" | ||
ENV APP_NAME operator | ||
|
||
COPY --from=builder /usr/bin/${APP_NAME} /go/bin/${APP_NAME} | ||
|