Browse Source

add docker build args

pull/218/head
jxlwqq 4 years ago
parent
commit
3b4410b8a4
  1. 5
      .github/workflows/release.yml
  2. 3
      helper/Dockerfile-release

5
.github/workflows/release.yml

@ -48,6 +48,9 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get Release Version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v2
with:
@ -57,3 +60,5 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
RELEASE_VERSION=${{ env.RELEASE_VERSION }}

3
helper/Dockerfile-release

@ -2,11 +2,12 @@
FROM --platform=$TARGETPLATFORM golang:1.16-alpine as builder
ARG TARGETARCH
ARG TARGETOS
ARG RELEASE_VERSION
WORKDIR /app/dtm
# RUN go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
EXPOSE 8080
COPY . .
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w"
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w -X main.Version=$RELEASE_VERSION"
FROM --platform=$TARGETPLATFORM alpine
COPY --from=builder /app/dtm/dtm /app/dtm/

Loading…
Cancel
Save