Skip to content

Commit

Permalink
Add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhiguo committed Oct 14, 2024
1 parent ea8f739 commit b55c21c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ARG BUILD_IMAGE=golang:alpine
FROM ${BUILD_IMAGE} AS builder
FROM golang:alpine AS builder

ENV SRC_PATH ${GOPATH}/src/joylive-injector

Expand All @@ -8,6 +7,7 @@ WORKDIR ${SRC_PATH}
COPY . .

RUN set -ex \
&& apk add git \
&& export BUILD_VERSION=$(cat version) \
&& export BUILD_DATE=$(date "+%F %T") \
&& export COMMIT_SHA1=$(git rev-parse HEAD) \
Expand All @@ -18,8 +18,7 @@ RUN set -ex \
-X 'main.commitID=${COMMIT_SHA1}' \
-w -s"

ARG RUNTIME_IMAGE=alpine
FROM ${RUNTIME_IMAGE}
FROM alpine

ARG TZ="Asia/Shanghai"

Expand All @@ -29,6 +28,7 @@ ENV LC_ALL en_US.UTF-8
ENV LANGUAGE en_US:en

RUN set -ex \
&& apk add bash tzdata ca-certificates \
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo ${TZ} > /etc/timezone \
&& rm -rf /var/cache/apk/*
Expand Down
42 changes: 42 additions & 0 deletions InnerBuild.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ARG BUILD_IMAGE=golang:alpine
FROM ${BUILD_IMAGE} AS builder

ENV SRC_PATH ${GOPATH}/src/joylive-injector

WORKDIR ${SRC_PATH}

COPY . .

ENV GO111MODULE=on
ENV GOPROXY http://jdos-goproxy.jdcloud.com,direct
ENV GOPRIVATE ""

RUN set -ex \
&& export BUILD_VERSION=$(cat version) \
&& export BUILD_DATE=$(date "+%F %T") \
&& export COMMIT_SHA1=$(git rev-parse HEAD) \
&& go mod tidy \
&& go install -trimpath -ldflags \
"-X 'main.version=${BUILD_VERSION}' \
-X 'main.buildDate=${BUILD_DATE}' \
-X 'main.commitID=${COMMIT_SHA1}' \
-w -s"

ARG RUNTIME_IMAGE=alpine
FROM ${RUNTIME_IMAGE}

ARG TZ="Asia/Shanghai"

ENV TZ ${TZ}
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV LANGUAGE en_US:en

RUN set -ex \
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
&& echo ${TZ} > /etc/timezone \
&& rm -rf /var/cache/apk/*

COPY --from=builder /go/bin/joylive-injector /joylive-injector

ENTRYPOINT ["/joylive-injector"]

0 comments on commit b55c21c

Please sign in to comment.