From 1e0c90547a8c9c68d607eeeb41e60b69c208906d Mon Sep 17 00:00:00 2001 From: Author Name Date: Mon, 29 Apr 2024 15:40:14 -0400 Subject: [PATCH] copy the license file into artifacts (#479) --- .github/workflows/build.yml | 16 ++++++++++++++-- Dockerfile | 14 ++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7061379..20d48ab9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -75,7 +75,16 @@ jobs: os: ${{ matrix.goos }} arch: ${{ matrix.goarch }} reproducible: assert - instructions: CGO_ENABLED=0 go build -trimpath -buildvcs=false -ldflags="-X github.com/hashicorp/consul-dataplane/pkg/version.GitCommit=${GITHUB_SHA::8}" -o $BIN_PATH ./cmd/$BIN_NAME + instructions: | + cp LICENSE $TARGET_DIR/LICENSE.txt + CGO_ENABLED=0 go build -trimpath -buildvcs=false -ldflags="-X github.com/hashicorp/consul-dataplane/pkg/version.GitCommit=${GITHUB_SHA::8}" -o $BIN_PATH ./cmd/$BIN_NAME + + - name: Copy license file + env: + LICENSE_DIR: ".release/linux/package/usr/share/doc/${{ env.PKG_NAME }}" + run: | + mkdir -p "$LICENSE_DIR" + cp LICENSE "$LICENSE_DIR/LICENSE.txt" - name: Package if: ${{ matrix.goos == 'linux' }} @@ -91,6 +100,7 @@ jobs: binary: "dist/${{ env.PKG_NAME }}" deb_depends: "openssl" rpm_depends: "openssl" + config_dir: ".release/linux/package/" - name: Set Package Names if: ${{ matrix.goos == 'linux' }} @@ -138,7 +148,9 @@ jobs: os: ${{ matrix.goos }} arch: ${{ matrix.goarch }} reproducible: assert - instructions: CGO_ENABLED=0 go build -trimpath -buildvcs=false -ldflags="-X github.com/hashicorp/consul-dataplane/pkg/version.GitCommit=${GITHUB_SHA::8}" -o $BIN_PATH ./cmd/$BIN_NAME + instructions: | + cp LICENSE $TARGET_DIR/LICENSE.txt + CGO_ENABLED=0 go build -trimpath -buildvcs=false -ldflags="-X github.com/hashicorp/consul-dataplane/pkg/version.GitCommit=${GITHUB_SHA::8}" -o $BIN_PATH ./cmd/$BIN_NAME build-docker-default: name: Docker ${{ matrix.arch }} default release build diff --git a/Dockerfile b/Dockerfile index d61d5c17..5b2745fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,7 +42,7 @@ ARG BIN_NAME=consul-dataplane ENV BIN_NAME=$BIN_NAME ARG PRODUCT_VERSION ARG PRODUCT_REVISION -ARG PRODUCT_NAME=$BIN_NAME +ENV PRODUCT_NAME=$BIN_NAME # TARGETARCH and TARGETOS are set automatically when --platform is provided. ARG TARGETOS TARGETARCH @@ -54,7 +54,10 @@ LABEL name=${BIN_NAME}\ release=${PRODUCT_REVISION} \ revision=${PRODUCT_REVISION} \ summary="Consul dataplane manages the proxy that runs within the data plane layer of Consul Service Mesh." \ - description="Consul dataplane manages the proxy that runs within the data plane layer of Consul Service Mesh." + description="Consul dataplane manages the proxy that runs within the data plane layer of Consul Service Mesh." \ + org.opencontainers.image.licenses="MPL-2.0" + +COPY LICENSE /usr/share/doc/$PRODUCT_NAME/LICENSE.txt COPY --from=dumb-init /usr/bin/dumb-init /usr/local/bin/ COPY --from=go-discover /go/bin/discover /usr/local/bin/ @@ -76,7 +79,7 @@ ARG BIN_NAME=consul-dataplane ENV BIN_NAME=$BIN_NAME ARG PRODUCT_VERSION ARG PRODUCT_REVISION -ARG PRODUCT_NAME=$BIN_NAME +ENV PRODUCT_NAME=$BIN_NAME # TARGETARCH and TARGETOS are set automatically when --platform is provided. ARG TARGETOS TARGETARCH @@ -87,7 +90,10 @@ LABEL name=${BIN_NAME}\ release=${PRODUCT_REVISION} \ revision=${PRODUCT_REVISION} \ summary="Consul dataplane connects an application to a Consul service mesh." \ - description="Consul dataplane connects an application to a Consul service mesh." + description="Consul dataplane connects an application to a Consul service mesh." \ + org.opencontainers.image.licenses="MPL-2.0" + +COPY LICENSE /usr/share/doc/$PRODUCT_NAME/LICENSE.txt RUN microdnf install -y shadow-utils