From f313d1ee0d6b88c4edf50527285eebc93dab8f42 Mon Sep 17 00:00:00 2001 From: Xinyi Wang Date: Wed, 25 Sep 2024 14:08:41 -0700 Subject: [PATCH] add license file to linux distribution and docker image --- .github/workflows/build.yml | 10 ++++++++++ Dockerfile | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a60259b2..89cd776d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,6 +100,7 @@ jobs: CGO_ENABLED: 0 run: | mkdir dist out + cp LICENSE dist/LICENSE.txt go build -o dist/ -ldflags "-s -w -X $(go list -m)/version.GitCommit=$(git rev-parse --short HEAD)" . zip -r -j out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip dist/ @@ -142,6 +143,7 @@ jobs: CGO_ENABLED: 0 run: | mkdir dist out + cp LICENSE dist/LICENSE.txt go build -o dist/ -ldflags "-s -w -X $(go list -m)/version.GitCommit=$(git rev-parse --short HEAD)" . zip -r -j out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip dist/ @@ -150,6 +152,13 @@ jobs: name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip path: out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip + - 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' }} uses: hashicorp/actions-packaging-linux@v1 @@ -164,6 +173,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' }} diff --git a/Dockerfile b/Dockerfile index f8952c09..94a15464 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ ARG BIN_NAME=envconsul 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 @@ -21,6 +21,7 @@ LABEL maintainer="John Eikenberry " # version label is required for build process LABEL version=$PRODUCT_VERSION LABEL revision=$PRODUCT_REVISION +LABEL licenses="MPL-2.0" # These are the defaults, this makes them explicit and overridable. ARG UID=100 @@ -31,6 +32,8 @@ RUN addgroup -g ${GID} ${BIN_NAME} \ # where the build system stores the builds COPY ./dist/$TARGETOS/$TARGETARCH/$BIN_NAME /bin/ +# copy the license file to the required directory +COPY LICENSE /usr/share/doc/$PRODUCT_NAME/LICENSE.txt # entrypoint COPY ./.release/docker-entrypoint.sh /bin/