-
Notifications
You must be signed in to change notification settings - Fork 1
WIP - Adding AWS Greengrass - Parsec Demo #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
grealish
wants to merge
7
commits into
master
Choose a base branch
from
building_parsec_workshop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
95fdbd3
adding git submodules, parsec test containers, build_demo script
grealish 6055ecb
adding ignore files for docker and git
grealish 6448eb8
various fixes to workshop demo and testing
grealish 98b588c
updating doc's to reflect PR description for initial demo testing
grealish 77d8b69
adding changes and removing unneeded submodule based on PR feedback a…
grealish de7e70b
fixed bugs to allow a clean demo run
elft3r aabf9c0
updated READMEs
elft3r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| *.iml | ||
| target | ||
| dependency-reduced-pom.xml | ||
| .flattened-pom.xml | ||
| .idea | ||
| .run/gg_* | ||
| .run/parsec_docker_run.run.xml | ||
| secrets.env | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| [submodule "greengrass_parsec_workshop/parsec-client-java"] | ||
| path = greengrass_parsec_workshop/parsec-client-java | ||
| url = https://github.com/parallaxsecond/parsec-client-java.git | ||
| branch = main | ||
| [submodule "greengrass_parsec_workshop/aws-greengrass-parsec-provider"] | ||
| path = greengrass_parsec_workshop/aws-greengrass-parsec-provider | ||
| url = https://github.com/56kcloud/aws-greengrass-parsec-provider.git | ||
| branch = main | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| build_demo.sh | ||
| greengrass_demo/.gitignore | ||
| secrets.env | ||
| target | ||
| .gitignore | ||
| .git | ||
| .cache | ||
| **/parsec_docker_cache | ||
| **/target | ||
| .idea | ||
| *.iml | ||
| .run | ||
| .flattened-pom.xml | ||
| *~ | ||
| .DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule aws-greengrass-parsec-provider
added at
6c338b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| #!/bin/bash | ||
| set -e | ||
| pushd $(dirname $0) | ||
| md5_cmd=md5 | ||
| md5_cmd=md5sum | ||
|
|
||
| if ! test -x /sbin/md5; then | ||
| md5_cmd=md5sum | ||
|
|
@@ -15,7 +15,12 @@ function update_git() { | |
| # Need to update the protobuf from parsec | ||
| git submodule init | ||
| git submodule update | ||
|
|
||
| pushd ./aws-greengrass-parsec-provider/ | ||
| git submodule init | ||
| git submodule update | ||
| pushd ./aws-greengrass-parsec-provider/parsec-client-java/ | ||
|
elft3r marked this conversation as resolved.
Outdated
|
||
| git submodule init | ||
| git submodule update | ||
| } | ||
|
|
||
| function dirty_build_on_new_comits() { | ||
|
|
@@ -30,13 +35,14 @@ function dirty_build_on_new_comits() { | |
| } | ||
|
|
||
| function build_greengrass_patched() { | ||
| pushd examples/greengrass/parsec-greengrass-run-config/docker/ | ||
| pushd ./aws-greengrass-parsec-provider/parsec-greengrass-run-config/docker/ | ||
| docker build . \ | ||
| --build-arg BUILD_TS=${DIRTY_TS} \ | ||
| --tag parallaxsecond/greengrass_patched:latest \ | ||
| --progress plain | ||
| popd | ||
| } | ||
|
|
||
| function copy_deps_from_greengrass_patched_to_local() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we still use this function? The local repository is not used for the demo build. I think it's left from some dev testing. |
||
| docker run -v ~/.m2/repository:/host_m2_repository parallaxsecond/greengrass_patched:latest \ | ||
| /bin/bash -c "cp -r ~/.m2/repository/* /host_m2_repository" | ||
|
|
@@ -49,6 +55,7 @@ popd | |
| } | ||
|
|
||
| function build_greengrass_with_provider() { | ||
| echo "Build of Greengrass and Parsec Plugin started..." | ||
| docker build . -f greengrass_demo/Dockerfile --tag parallaxsecond/greengrass_demo:latest --progress plain | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| FROM parallaxsecond/greengrass_patched:latest as from_source_builder | ||
| COPY ./ /project | ||
| RUN cd /project && \ | ||
| RUN cd /project/aws-greengrass-parsec-provider && \ | ||
| ./mvnw clean install -DskipTests=true -Dcontainers.skip=true | ||
|
|
||
| FROM parallaxsecond/greengrass_patched:latest | ||
| COPY --from=from_source_builder /project/examples/greengrass/parsec-greengrass-plugin/target/aws.greengrass.crypto.ParsecProvider.jar /provider.jar | ||
| COPY --from=from_source_builder /project/aws-greengrass-parsec-provider/parsec-greengrass-plugin/target/aws.greengrass.crypto.ParsecProvider.jar /provider.jar | ||
| COPY greengrass_demo/config.yml /greengrass/ |
Submodule parsec-client-java
added at
1e44b2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| parsec_docker_cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/bin/bash -e | ||
| docker_cache=parsec_docker_cache | ||
|
|
||
| CACHE_CONFIG="" | ||
| if (docker buildx inspect |grep "Driver: docker-container"); then | ||
| CACHE_CONFIG=" --set *.cache-from=type=local,src=${docker_cache} --set *.cache-to=mode=max,type=local,dest=${docker_cache}_new" | ||
| fi | ||
|
|
||
| # shellcheck disable=SC2086 | ||
| docker buildx bake ${CACHE_CONFIG} \ | ||
| --progress plain \ | ||
| --load | ||
|
|
||
| rm -rf ${docker_cache} || true | ||
| mv ${docker_cache}_new ${docker_cache} || true |
38 changes: 38 additions & 0 deletions
38
greengrass_parsec_workshop/parsec-testcontainers/docker-bake.hcl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| group "default" { | ||
| #targets = ["parsec", "parsec_0.7.0", "parsec_0.8.1"] | ||
| targets = ["parsec_0.8.1"] | ||
| } | ||
| target "generic" { | ||
| context = "." | ||
| args = { | ||
| REGISTRY = "parallaxsecond" | ||
| } | ||
| } | ||
| target "parsec" { | ||
| inherits = ["generic"] | ||
| context = "./parsec" | ||
| args = { | ||
| PARSEC_BRANCH = "main" | ||
| } | ||
| tags = [ | ||
| "parallaxsecond/parsec:latest" | ||
| ] | ||
| } | ||
| target "parsec_0.8.1" { | ||
| inherits = ["parsec"] | ||
| args = { | ||
| PARSEC_BRANCH = "0.8.1" | ||
| } | ||
| tags = [ | ||
| "parallaxsecond/parsec:0.8.1" | ||
| ] | ||
| } | ||
| target "parsec_0.7.0" { | ||
| inherits = ["parsec"] | ||
| args = { | ||
| PARSEC_BRANCH = "0.7.0" | ||
| } | ||
| tags = [ | ||
| "parallaxsecond/parsec:0.7.0" | ||
| ] | ||
| } |
72 changes: 72 additions & 0 deletions
72
greengrass_parsec_workshop/parsec-testcontainers/parsec/Dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| ARG REGISTRY | ||
| FROM amazonlinux:2 as builder | ||
|
|
||
| RUN set -e -x; \ | ||
| yum install -y git gcc shadow-utils cmake3 make gcc-c++ pkgconfig clang-devel;\ | ||
| rm -rf /root/.cache && \ | ||
| yum clean all && \ | ||
| rm -rf /var/cache/yum && \ | ||
| rpm --rebuilddb && \ | ||
| ln -s /usr/bin/cmake3 /usr/bin/cmake | ||
|
|
||
| RUN curl https://sh.rustup.rs -sSf | sh -s -- -y | ||
|
|
||
| # Workaround for incorrect aarch64 entry in cargo build | ||
| RUN ln -s /usr/bin/gcc /usr/bin/aarch64-linux-gnu-gcc | ||
|
|
||
| ARG PARSEC_TOOL_VERSION=0.4.0 | ||
| RUN set -e -x; \ | ||
| source $HOME/.cargo/env; \ | ||
| git clone https://github.com/parallaxsecond/parsec-tool; \ | ||
| cd parsec-tool; \ | ||
| git checkout ${PARSEC_TOOL_VERSION}; \ | ||
| cargo install --path .; \ | ||
| cd ..; \ | ||
| rm -rf parsec-tool | ||
|
|
||
| ARG PARSEC_BRANCH=0.8.1 | ||
| ARG PARSEC_FEATURES="cryptoauthlib-provider,mbed-crypto-provider,unix-peer-credentials-authenticator,direct-authenticator" | ||
| RUN set -e -x; \ | ||
| source $HOME/.cargo/env; \ | ||
| git clone https://github.com/parallaxsecond/parsec; \ | ||
| cd parsec; \ | ||
| git checkout ${PARSEC_BRANCH}; \ | ||
| cargo install --features "${PARSEC_FEATURES}" --path .; \ | ||
| cd ..; \ | ||
| rm -rf parsec | ||
|
|
||
| ARG PARSEC_UID=4000 | ||
| ARG PARSEC_GID=4000 | ||
| RUN set -e -x; \ | ||
| groupadd -g ${PARSEC_GID} parsec; \ | ||
| useradd -u ${PARSEC_UID} -g ${PARSEC_GID} -d /home/parsec parsec; \ | ||
| mkdir -p /var/lib/parsec /home/parsec /run/parsec /etc/parsec /usr/libexec/parsec; \ | ||
| chmod 700 /var/lib/parsec /etc/parsec /usr/libexec/parsec; \ | ||
| chmod 755 /run/parsec; | ||
|
|
||
| FROM amazonlinux:2 as run | ||
| ENV RUST_LOG=info | ||
| ARG PARSEC_UID=4000 | ||
| ARG PARSEC_GID=4000 | ||
|
|
||
| RUN yum install -y socat && \ | ||
| rm -rf /root/.cache && \ | ||
| yum clean all && \ | ||
| rm -rf /var/cache/yum && \ | ||
| rpm --rebuilddb | ||
|
|
||
| COPY --from=builder /etc/passwd /etc/passwd | ||
| COPY --from=builder /etc/group /etc/group | ||
| COPY --from=builder /root/.cargo/bin/parsec* /usr/bin/ | ||
| COPY config.toml /etc/parsec/ | ||
| COPY --from=builder --chown=${PARSEC_UID}:${PARSEC_GID} /usr/libexec/parsec /usr/libexec/parsec | ||
| COPY --from=builder --chown=${PARSEC_UID}:${PARSEC_GID} /var/lib/parsec /var/lib/parsec | ||
| COPY --from=builder --chown=${PARSEC_UID}:${PARSEC_GID} /home/parsec /home/parsec | ||
| COPY --from=builder --chown=${PARSEC_UID}:${PARSEC_GID} /run/parsec /run/parsec | ||
| COPY --from=builder --chown=${PARSEC_UID}:${PARSEC_GID} /etc/parsec /etc/parsec | ||
|
|
||
| # FIXME volume mount problem | ||
| # Volumes are mounted as root first | ||
| #USER parsec:parsec | ||
| WORKDIR "/home/parsec" | ||
| CMD ["parsec", "-c", "/etc/parsec/config.toml"] |
22 changes: 22 additions & 0 deletions
22
greengrass_parsec_workshop/parsec-testcontainers/parsec/config.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| [core_settings] | ||
| log_timestamp = true | ||
| log_error_details = true | ||
| allow_root = true | ||
|
|
||
| [listener] | ||
| listener_type = "DomainSocket" | ||
| timeout = 200 # in milliseconds | ||
| socket_path = "/run/parsec/parsec.sock" | ||
|
|
||
| [authenticator] | ||
| auth_type = "UnixPeerCredentials" | ||
| admins = [ { name = "root" }, { name = "parsec" } ] | ||
|
|
||
| [[key_manager]] | ||
| name = "on-disk-manager" | ||
| manager_type = "OnDisk" | ||
| store_path = "/var/lib/parsec/mappings" | ||
|
|
||
| [[provider]] | ||
| provider_type = "MbedCrypto" | ||
| key_info_manager = "on-disk-manager" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>org.parallaxsecond</groupId> | ||
| <artifactId>parsec-java</artifactId> | ||
| <version>1.0.0-SNAPSHOT</version> | ||
| <relativePath>..</relativePath> | ||
| </parent> | ||
| <artifactId>parsec-testcontainers</artifactId> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>junit-jupiter</artifactId> | ||
| <version>1.16.2</version> | ||
| </dependency> | ||
| </dependencies> | ||
| <properties> | ||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| <maven.compiler.source>1.8</maven.compiler.source> | ||
| <maven.compiler.target>1.8</maven.compiler.target> | ||
| <containers.skip>false</containers.skip> | ||
| </properties> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <!-- using exec plugin since fabric8 uses jffi not supported on m1 yet --> | ||
| <groupId>org.codehaus.mojo</groupId> | ||
| <artifactId>exec-maven-plugin</artifactId> | ||
| <version>3.0.0</version> | ||
| <executions> | ||
| <execution> | ||
| <id>buildx</id> | ||
| <goals> | ||
| <goal>exec</goal> | ||
| </goals> | ||
| <phase>package</phase> | ||
| <configuration> | ||
| <skip>${containers.skip}</skip> | ||
| <executable>./build.sh</executable> | ||
| <workingDirectory>${project.basedir}</workingDirectory> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.