From 9952fc72969ded7489b2b1a07c0e1ff4eeb0ca44 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 13 Jan 2021 00:09:37 +0000 Subject: [PATCH 1/5] feat(studio): add optimized Dockerfile --- lib/Studio.js | 8 ++------ plan.sh | 2 +- studio/.dockerignore | 3 +++ studio/Dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ studio/plan.sh | 4 ++-- 5 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 studio/.dockerignore create mode 100644 studio/Dockerfile diff --git a/lib/Studio.js b/lib/Studio.js index b09fba57..f7bf629a 100644 --- a/lib/Studio.js +++ b/lib/Studio.js @@ -198,13 +198,9 @@ class Studio { const { uid, gid, username } = os.userInfo(); - if (username) { + if (uid && gid && username) { logger.info(`configuring container to use user: ${username}`); - await containerExec(container, '/bin/mkdir', '/home'); - await containerExec(container, '/bin/adduser', '-u', `${uid}`, '-D', username); - await containerExec(container, '/bin/chown', '-R', username, '/hab/cache'); - await containerExec(container, '/bin/find', '/hab/pkgs', '-maxdepth', '3', '-type', 'd', '-exec', 'chown', `-R`, username, '{}', ';'); - await containerExec(container, '/bin/hab', 'pkg', 'install', '--binlink', '--force', 'core/tar'); + await containerExec(container, 'adduser', '-u', `${uid}`, '-G', 'developer', '-D', username); container.defaultUser = `${uid}:${gid}`; } diff --git a/plan.sh b/plan.sh index ef421f1f..ad452835 100644 --- a/plan.sh +++ b/plan.sh @@ -11,7 +11,7 @@ pkg_build_deps=( pkg_deps=( core/git jarvus/node12 # newer than core/node12 - core/hab/0.79.0 # last version before new license + core/hab/0.79.1 # last version before new license ) pkg_bin_dirs=(bin) diff --git a/studio/.dockerignore b/studio/.dockerignore new file mode 100644 index 00000000..926547cb --- /dev/null +++ b/studio/.dockerignore @@ -0,0 +1,3 @@ +.dockerignore +Dockerfile +results/ diff --git a/studio/Dockerfile b/studio/Dockerfile new file mode 100644 index 00000000..15cf7ee5 --- /dev/null +++ b/studio/Dockerfile @@ -0,0 +1,42 @@ +# common base for both stages +FROM habitat/default-studio-x86_64-linux:0.79.1 as base + +ARG HAB_LICENSE=no-accept +ENV HAB_LICENSE=$HAB_LICENSE +ENV HAB_ORIGIN=jarvus +RUN hab origin key generate + + +# intermediary stage used to build hologit-studio package +FROM base as builder + +RUN hab pkg install core/hab-plan-build/0.79.1 +COPY . /src +RUN hab pkg exec core/hab-plan-build hab-plan-build /src + + +# final stage to be published +FROM base as studio + +ENTRYPOINT ["hab", "sup", "run"] +CMD ["jarvus/hologit-studio"] + +COPY --from=builder /hab/cache/artifacts /hab/cache/artifacts +RUN hab pkg install \ + /hab/cache/artifacts/$HAB_ORIGIN-hologit-studio-* \ + core/hab-sup/0.79.1 \ + core/hab-launcher/10180 \ + core/tar \ + core/gcc \ + && hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/ + +RUN hab pkg binlink core/busybox-static \ + && hab pkg binlink --dest /usr/bin core/busybox-static env \ + && hab pkg binlink --force core/tar + +RUN mkdir -m 1777 -p /tmp \ + && mkdir -m 0750 -p /root \ + && mkdir -m 0755 -p /usr/bin /home \ + && addgroup developer \ + && chgrp -R developer /hab \ + && chmod -R g+w /hab diff --git a/studio/plan.sh b/studio/plan.sh index c468cace..7d5c2768 100644 --- a/studio/plan.sh +++ b/studio/plan.sh @@ -6,10 +6,10 @@ pkg_license=("MIT") pkg_maintainer="Chris Alfano " pkg_build_deps=( - core/hab + core/hab/0.79.1 ) pkg_deps=( - core/coreutils + core/busybox-static jarvus/hologit ) From 5b97806758afa8c5424170b4ca16e6435582055d Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 13 Jan 2021 01:47:04 +0000 Subject: [PATCH 2/5] chore: switch to node14 --- .studiorc | 4 ++-- github-actions/projector/action.yml | 2 +- plan.sh | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.studiorc b/.studiorc index 60f71003..5fbfbc20 100644 --- a/.studiorc +++ b/.studiorc @@ -7,10 +7,10 @@ echo "--> Installing project development dependencies..." hab pkg install \ jarvus/mkdocs-studio \ jarvus/studio-toolkit \ - jarvus/node12 \ + jarvus/node14 \ core/git -hab pkg binlink jarvus/node12 core/git +hab pkg binlink jarvus/node14 core/git hab pkg binlink core/coreutils env --dest /usr/bin diff --git a/github-actions/projector/action.yml b/github-actions/projector/action.yml index c9ec2c85..db61ae21 100644 --- a/github-actions/projector/action.yml +++ b/github-actions/projector/action.yml @@ -16,6 +16,6 @@ outputs: commit: description: 'Commit hash for last projection (if commit-to is configured)' runs: - using: 'node12' + using: 'node14' main: 'index.js' post: 'post.js' diff --git a/plan.sh b/plan.sh index ad452835..495ec845 100644 --- a/plan.sh +++ b/plan.sh @@ -10,7 +10,7 @@ pkg_build_deps=( pkg_deps=( core/git - jarvus/node12 # newer than core/node12 + jarvus/node14 # newer than core/node12 core/hab/0.79.1 # last version before new license ) @@ -39,7 +39,7 @@ do_build() { npm install build_line "Fixing interpreter" - sed -e "s#\#\!/usr/bin/env node#\#\!$(pkg_path_for node12)/bin/node#" --in-place "node-bin/cli.js" + sed -e "s#\#\!/usr/bin/env node#\#\!$(pkg_path_for node14)/bin/node#" --in-place "node-bin/cli.js" popd > /dev/null } From b5cc3fe3c1522d76d590c5acc90f7ba91c870a02 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 13 Jan 2021 02:13:52 +0000 Subject: [PATCH 3/5] chore: switch default package version to 0.0.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 15276fdf..4bd31878 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hologit", - "version": "0.34.5", + "version": "0.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a84aabdb..624c13d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hologit", - "version": "0.34.5", + "version": "0.0.1", "description": "Hologit automates the projection of layered composite file trees based on flat, declarative plans", "repository": "https://github.com/EmergencePlatform/hologit", "main": "lib/index.js", From 2573921d7a9ca279b198608c437efcfc2cff256d Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 13 Jan 2021 01:53:01 +0000 Subject: [PATCH 4/5] feat: add publish-habitat workflow --- .github/workflows/publish-habitat.yml | 86 +++++++++++++++++++++++++++ studio/Dockerfile | 19 ++---- studio/plan.sh | 4 +- 3 files changed, 92 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/publish-habitat.yml diff --git a/.github/workflows/publish-habitat.yml b/.github/workflows/publish-habitat.yml new file mode 100644 index 00000000..c368fef5 --- /dev/null +++ b/.github/workflows/publish-habitat.yml @@ -0,0 +1,86 @@ +name: Publish Habitat package and studio + +on: + push: + tags: [ 'v*' ] + +env: + HAB_LICENSE: accept-no-persist + + +jobs: + publish-habitat: + runs-on: ubuntu-latest + steps: + - name: 'Initialize Chef Habitat environment' + uses: JarvusInnovations/habitat-action@action/v1 + with: + deps: | + core/hab-plan-build + + - uses: actions/checkout@v2 + - name: Place tag in environment + run: | + echo "SOURCE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV + echo "REPO_NAME=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV + + - name: Import origin key + run: | + hab origin key import <> $GITHUB_ENV + + - name: Upload jarvus/hologit + env: + HAB_AUTH_TOKEN: '${{ secrets.HAB_AUTH_TOKEN }}' + run: | + source results/last_build.env + hab pkg upload "results/${pkg_artifact}" -c stable + + - name: Build jarvus/hologit-studio + run: | + hab pkg exec core/hab-plan-build hab-plan-build studio + + source results/last_build.env + echo "HOLOGIT_STUDIO_PACKAGE=jarvus/hologit-studio/${pkg_version}/${pkg_release}" >> $GITHUB_ENV + + - name: Upload jarvus/hologit-studio + env: + HAB_AUTH_TOKEN: '${{ secrets.HAB_AUTH_TOKEN }}' + run: | + source results/last_build.env + hab pkg upload "results/${pkg_artifact}" -c stable + + - name: Pull previous jarvus/hologit-studio:latest + run: docker pull jarvus/hologit-studio:latest || true + + - name: Build new jarvus/hologit-studio:latest + run: | + docker build \ + --build-arg "HOLOGIT_STUDIO_PACKAGE=${HOLOGIT_STUDIO_PACKAGE}" \ + --cache-from "jarvus/hologit-studio:latest" \ + --tag "jarvus/hologit-studio:latest" \ + --tag "jarvus/hologit-studio:${SOURCE_TAG#v}" \ + ./studio + + - name: Log into DockerHub + run: | + mkdir -p ~/.docker + echo "${{ secrets.DOCKER_CONFIG_BASE64 }}" | base64 -d > ~/.docker/config.json + + - name: Push new jarvus/hologit-studio:latest + run: docker push jarvus/hologit-studio:latest diff --git a/studio/Dockerfile b/studio/Dockerfile index 15cf7ee5..727f1993 100644 --- a/studio/Dockerfile +++ b/studio/Dockerfile @@ -4,26 +4,11 @@ FROM habitat/default-studio-x86_64-linux:0.79.1 as base ARG HAB_LICENSE=no-accept ENV HAB_LICENSE=$HAB_LICENSE ENV HAB_ORIGIN=jarvus -RUN hab origin key generate - - -# intermediary stage used to build hologit-studio package -FROM base as builder - -RUN hab pkg install core/hab-plan-build/0.79.1 -COPY . /src -RUN hab pkg exec core/hab-plan-build hab-plan-build /src - - -# final stage to be published -FROM base as studio ENTRYPOINT ["hab", "sup", "run"] CMD ["jarvus/hologit-studio"] -COPY --from=builder /hab/cache/artifacts /hab/cache/artifacts RUN hab pkg install \ - /hab/cache/artifacts/$HAB_ORIGIN-hologit-studio-* \ core/hab-sup/0.79.1 \ core/hab-launcher/10180 \ core/tar \ @@ -40,3 +25,7 @@ RUN mkdir -m 1777 -p /tmp \ && addgroup developer \ && chgrp -R developer /hab \ && chmod -R g+w /hab + +ARG HOLOGIT_STUDIO_PACKAGE=jarvus/hologit-studio +RUN hab pkg install $HOLOGIT_STUDIO_PACKAGE \ + && hab pkg exec core/coreutils rm -rf /hab/cache/{artifacts,src}/ diff --git a/studio/plan.sh b/studio/plan.sh index 7d5c2768..3f3c9f92 100644 --- a/studio/plan.sh +++ b/studio/plan.sh @@ -10,7 +10,7 @@ pkg_build_deps=( ) pkg_deps=( core/busybox-static - jarvus/hologit + ${HOLOGIT_PACKAGE:-jarvus/hologit} ) pkg_exports=( @@ -22,7 +22,7 @@ pkg_svc_run="git-holo studio --socket ${pkg_svc_var_path}/studio.sock" pkg_version() { - hab pkg path jarvus/hologit | cut -d/ -f6 + hab pkg path ${HOLOGIT_PACKAGE:-jarvus/hologit} | cut -d/ -f6 } # implement build workflow From 8b1443f19b8ddd15bf9e219f65a344b0cb8320c7 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Wed, 13 Jan 2021 04:20:23 +0000 Subject: [PATCH 5/5] refactor(ci): clean up workflow names --- .github/workflows/publish-actions-develop.yml | 2 +- .github/workflows/publish-actions-v1.yml | 4 ++-- .github/workflows/{docs-site.yml => publish-website.yml} | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) rename .github/workflows/{docs-site.yml => publish-website.yml} (90%) diff --git a/.github/workflows/publish-actions-develop.yml b/.github/workflows/publish-actions-develop.yml index c0f85e37..d31b9499 100644 --- a/.github/workflows/publish-actions-develop.yml +++ b/.github/workflows/publish-actions-develop.yml @@ -1,4 +1,4 @@ -name: Public Actions to develop stream +name: Publish Actions to develop stream on: push: diff --git a/.github/workflows/publish-actions-v1.yml b/.github/workflows/publish-actions-v1.yml index 0b6165a1..d4dfe3d3 100644 --- a/.github/workflows/publish-actions-v1.yml +++ b/.github/workflows/publish-actions-v1.yml @@ -1,8 +1,8 @@ -name: Public Actions to v1 stream +name: Publish Actions to v1 stream on: push: - branches: [master] + tags: [ 'v*' ] jobs: diff --git a/.github/workflows/docs-site.yml b/.github/workflows/publish-website.yml similarity index 90% rename from .github/workflows/docs-site.yml rename to .github/workflows/publish-website.yml index eba2c46b..e530d36d 100644 --- a/.github/workflows/docs-site.yml +++ b/.github/workflows/publish-website.yml @@ -1,11 +1,12 @@ -name: Docs Site +name: Publish Website on: push: branches: [ develop ] + jobs: - docs-projection: + publish-website: runs-on: ubuntu-latest steps: - name: 'Projecting docs-site holobranch onto gh-pages'