Browse Source
Merge pull request #218 from jxlwqq/build-args
add docker build args
pull/222/head
yedf2
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
7 additions and
1 deletions
-
.github/workflows/release.yml
-
helper/Dockerfile-release
|
|
|
@ -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 }} |
|
|
|
@ -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/ |
|
|
|
|