From 8a8afaae7a937f9de9867f8e0f9df5fae36ecb0b Mon Sep 17 00:00:00 2001 From: Christian Bormann Date: Tue, 25 Jan 2022 17:10:48 +0100 Subject: [PATCH 1/7] Add docker build and contributing text Signed-off-by: Christian Bormann --- .github/workflows/docker-image.yaml | 41 ++++++++++++ CONTRIBUTING.md | 97 +++++++++++++++++++++++++++++ about.hbs | 70 +++++++++++++++++++++ about.toml | 7 +++ docker/Dockerfile | 40 ++++++++++++ 5 files changed, 255 insertions(+) create mode 100644 .github/workflows/docker-image.yaml create mode 100644 CONTRIBUTING.md create mode 100644 about.hbs create mode 100644 about.toml create mode 100644 docker/Dockerfile diff --git a/.github/workflows/docker-image.yaml b/.github/workflows/docker-image.yaml new file mode 100644 index 0000000..e22a786 --- /dev/null +++ b/.github/workflows/docker-image.yaml @@ -0,0 +1,41 @@ +name: Create and publish a Docker image + +on: + push: + tags: + - 'v*' + paths-ignore: + - '**.md' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ needs.workflow_setup.outputs.repo_owner }}/{{ github.repository }}/indy-did-driver + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ghcr.io/${IMAGE_NAME} + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + file: docker/Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..0dd2add --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,97 @@ +# Contributing to a IDUnion project + +Want to contribute? That's great! Any contribution is welcome, e.g. +documentation, bug reports, feature request, issues, blog posts, +tutorials, feature implementations, etc. You can contribute code or +documentation through the standard GitHub pull request model. + +## Contribution Guideline + +* We use the GitHub issue tracker + +* When you want to submit a patch, you must [sign your + commits](#sign-your-work). + +* Your contribution must be licensed under the Apache-2.0 license, the + license used by this project. + +## Legal stuff + +### Sign your work + +This project also tracks patch provenance and licensing using the Developer +Certificate of Origin and Signed-off-by tags initially developed by +the Linux kernel project. + +```text +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +1 Letterman Drive +Suite D4700 +San Francisco, CA, 94129 + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. +``` + +With the sign-off in a commit message you certify that you authored the +patch or otherwise have the right to submit it under an open source +license. The procedure is simple: To certify above Developer's +Certificate of Origin 1.1 for your contribution just append a line + +```text +Signed-off-by: Random J Developer +``` + +to every commit message using your real name or your pseudonym and a valid +email address. + +If you have set your `user.name` and `user.email` git configs you can +automatically sign the commit by running the git-commit command with the +`-s` option. There may be multiple sign-offs if more than one developer +was involved in authoring the contribution. + +For a more detailed description of this procedure, please see +[SubmittingPatches][] which was extracted from the Linux kernel project, +and which is stored in an external repository. + +### Individual vs. Corporate Contributors + +Often employers or academic institution have ownership over code that is +written in certain circumstances, so please do due diligence to ensure that +you have the right to submit the code. + +If you are a developer who is authorized to contribute to IDUnion on behalf of your employer, then please use your corporate email address in the +Signed-off-by tag, otherwise use a personal email address. + +[SubmittingPatches]: +https://github.com/wking/signed-off-by/blob/7d71be37194df05c349157a2161c7534feaf86a4/Documentation/SubmittingPatches diff --git a/about.hbs b/about.hbs new file mode 100644 index 0000000..dd419d9 --- /dev/null +++ b/about.hbs @@ -0,0 +1,70 @@ + + + + + + + +
+
+

Third Party Licenses

+

This page lists the licenses of the projects used in indy-did-resolver.

+
+ +

Overview of licenses:

+
    + {{#each overview}} +
  • {{name}} ({{count}})
  • + {{/each}} +
+ +

All license text:

+ +
+ + + diff --git a/about.toml b/about.toml new file mode 100644 index 0000000..20da568 --- /dev/null +++ b/about.toml @@ -0,0 +1,7 @@ +accepted = [ + "Apache-2.0", + "MIT", + "CC0-1.0", + "BSD-3-Clause", + "Zlib" +] diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..3d69bdb --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,40 @@ +ARG RUST_VER=1.58 + +FROM rust:${RUST_VER}-buster as builder +USER root +ENV LANG=C.UTF-8 \ + CARGO_HOME="/root/.cargo" \ + USER="root" + +RUN mkdir -p ${CARGO_HOME} +RUN mkdir -p /app +RUN apt-get update && apt-get install -y libzmq3-dev cmake + +# Copy sources and build +WORKDIR /app +COPY . . +RUN cargo build --release + +RUN cargo install --locked cargo-about +RUN cargo about generate about.hbs > licenses.html + + +FROM debian:buster-slim +USER root +RUN apt-get update && apt-get install ca-certificates -y && rm -rf /var/lib/apt/lists/* + +COPY --from=builder /app/target/release/indy-did-driver /app/ +COPY --from=builder /app/indy-did-driver/genesis-files /app/ + +COPY --from=builder /app/licenses.html /app/ + +#RUN groupadd runner && useradd -r -g runner runner +#USER runner + +EXPOSE 8080 + +RUN printf "General information about third-party software components and their licenses, \ +which are distributed with this image, can be found in the the licenses.html \ +file distributed with this image at /app/licenses.html."\ + +ENTRYPOINT ["/app/indy-did-driver"] From a0bc9b1cf68dc19cd8ef299a0a9c1f760f85b4ac Mon Sep 17 00:00:00 2001 From: Christian Bormann Date: Wed, 26 Jan 2022 08:54:49 +0100 Subject: [PATCH 2/7] Allow for dead code in ledger struct Signed-off-by: Christian Bormann --- indy-did-driver/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/indy-did-driver/src/main.rs b/indy-did-driver/src/main.rs index 383b3f4..c480fc0 100644 --- a/indy-did-driver/src/main.rs +++ b/indy-did-driver/src/main.rs @@ -14,6 +14,7 @@ use indy_didresolver::error::{DidIndyError, DidIndyResult}; use rouille::Response; use serde_json::Value::Null; +#[allow(dead_code)] struct Ledger { name: String, //TODO: Source(local,github) From 403fcc694dc6f42e192388f822f323e2a1dbcf71 Mon Sep 17 00:00:00 2001 From: Christian Bormann Date: Thu, 27 Jan 2022 16:03:04 +0100 Subject: [PATCH 3/7] Fix Dockerfile and container build action Signed-off-by: Christian Bormann --- .../{docker-image.yaml => container-release.yaml} | 12 +++++++----- docker/Dockerfile | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) rename .github/workflows/{docker-image.yaml => container-release.yaml} (69%) diff --git a/.github/workflows/docker-image.yaml b/.github/workflows/container-release.yaml similarity index 69% rename from .github/workflows/docker-image.yaml rename to .github/workflows/container-release.yaml index e22a786..576fc08 100644 --- a/.github/workflows/docker-image.yaml +++ b/.github/workflows/container-release.yaml @@ -9,7 +9,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ needs.workflow_setup.outputs.repo_owner }}/{{ github.repository }}/indy-did-driver + IMAGE_NAME: ${{ github.repository }}/indy-did-driver jobs: build-and-push-image: @@ -21,18 +21,20 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + uses: docker/login-action@v1 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v3 with: - images: ghcr.io/${IMAGE_NAME} + images: ghcr.io/${{ env.IMAGE_NAME }} + flavor: | + latest=auto - name: Build and push Docker image - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@v2 with: context: . push: true diff --git a/docker/Dockerfile b/docker/Dockerfile index 3d69bdb..978fc83 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -15,6 +15,7 @@ WORKDIR /app COPY . . RUN cargo build --release +# Check licenses and generate report RUN cargo install --locked cargo-about RUN cargo about generate about.hbs > licenses.html @@ -35,6 +36,6 @@ EXPOSE 8080 RUN printf "General information about third-party software components and their licenses, \ which are distributed with this image, can be found in the the licenses.html \ -file distributed with this image at /app/licenses.html."\ +file distributed with this image at /app/licenses.html." ENTRYPOINT ["/app/indy-did-driver"] From a81eadfab7e1320fa42f082bac6afc9be4221d2e Mon Sep 17 00:00:00 2001 From: Christian Bormann Date: Thu, 27 Jan 2022 16:03:28 +0100 Subject: [PATCH 4/7] Trigger cargo tests on pull request Signed-off-by: Christian Bormann --- .github/workflows/pull-request-test.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/pull-request-test.yaml diff --git a/.github/workflows/pull-request-test.yaml b/.github/workflows/pull-request-test.yaml new file mode 100644 index 0000000..56a4d73 --- /dev/null +++ b/.github/workflows/pull-request-test.yaml @@ -0,0 +1,18 @@ +name: Run tests on pull request + +on: + pull_request: + +jobs: + build_and_test: + name: Rust project + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - uses: actions-rs/cargo@v1 + with: + command: test + args: --release --all-features From 8c6af42a2b56463e640129452f1c76753d0c3fa4 Mon Sep 17 00:00:00 2001 From: Christian Bormann Date: Thu, 27 Jan 2022 17:19:59 +0100 Subject: [PATCH 5/7] Add License information Signed-off-by: Christian Bormann --- LICENSE | 201 ++++++++++++++++++++++++++++++++++++ indy-did-driver/Cargo.toml | 1 + indy-didresolver/Cargo.toml | 1 + 3 files changed, 203 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7212311 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2020-2021 by all parties listed in the NOTICE file + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/indy-did-driver/Cargo.toml b/indy-did-driver/Cargo.toml index 54419e9..eb6e2fb 100644 --- a/indy-did-driver/Cargo.toml +++ b/indy-did-driver/Cargo.toml @@ -3,6 +3,7 @@ name = "indy-did-driver" version = "0.1.0" authors = ["Paul Bastian "] edition = "2018" +license = "Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/indy-didresolver/Cargo.toml b/indy-didresolver/Cargo.toml index edfe122..4ca28b2 100644 --- a/indy-didresolver/Cargo.toml +++ b/indy-didresolver/Cargo.toml @@ -2,6 +2,7 @@ name = "indy-didresolver" version = "0.1.0" edition = "2021" +license = "Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 07628f86728152499125f266ac65d74d22942212 Mon Sep 17 00:00:00 2001 From: Christian Bormann Date: Thu, 27 Jan 2022 17:25:10 +0100 Subject: [PATCH 6/7] Fix working directory in dockerfile Signed-off-by: Christian Bormann --- docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 978fc83..282ce13 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -25,7 +25,7 @@ USER root RUN apt-get update && apt-get install ca-certificates -y && rm -rf /var/lib/apt/lists/* COPY --from=builder /app/target/release/indy-did-driver /app/ -COPY --from=builder /app/indy-did-driver/genesis-files /app/ +COPY --from=builder /app/indy-did-driver/genesis-files /app/genesis-files COPY --from=builder /app/licenses.html /app/ @@ -38,4 +38,5 @@ RUN printf "General information about third-party software components and their which are distributed with this image, can be found in the the licenses.html \ file distributed with this image at /app/licenses.html." +WORKDIR /app ENTRYPOINT ["/app/indy-did-driver"] From 2db266c811f32ab6b843732217578f11770ac035 Mon Sep 17 00:00:00 2001 From: Christian Bormann Date: Thu, 27 Jan 2022 17:47:11 +0100 Subject: [PATCH 7/7] Use different user within container Signed-off-by: Christian Bormann --- docker/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 282ce13..dd82d75 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -29,8 +29,8 @@ COPY --from=builder /app/indy-did-driver/genesis-files /app/genesis-files COPY --from=builder /app/licenses.html /app/ -#RUN groupadd runner && useradd -r -g runner runner -#USER runner +RUN groupadd runner && useradd -r -g runner runner +USER runner EXPOSE 8080