diff --git a/app/build_npms.py b/app/build_npms.py index 81b215a..812fb5c 100644 --- a/app/build_npms.py +++ b/app/build_npms.py @@ -20,7 +20,6 @@ import os from decouple import config -import subprocess import click import pkg_resources from python_on_whales import docker @@ -56,20 +55,12 @@ def command(ctx, include, exclude): if verbose: print(f'Packages: {packages}') - # To build a package we need to run the cerc/build-js container with a bind mount from the project directory - # and use docker run to execute the build script inside that container - # docker.run("cerc/builder-js", ["ls", "/host"], volumes=[("", "/workspace")]) - # sh -c 'cd /workspace && NPM_AUTH_TOKEN=6613572a28ebebaee20ccd90064251fa8c2b94f6 \ - # build-npm-package.sh http://host.docker.internal:3000/api/packages/cerc-io/npm/ 1.0.0-beta.1' - # NPM_AUTH_TOKEN=6613572a28ebebaee20ccd90064251fa8c2b94f6 - # Set uid/gid - def build_package(package): if not quiet: print(f"Building: {package}") repo_dir = package repo_full_path = os.path.join(dev_root_path, repo_dir) - build_command = ["sh", "-c", "'cd /workspace && build-npm-package.sh http://host.docker.internal:3000/api/packages/cerc-io/npm/ 1.0.0-beta.1'"] + build_command = ["sh", "-c", "cd /workspace && build-npm-package.sh http://host.docker.internal:3000/api/packages/cerc-io/npm/ 1.0.15"] if not dry_run: if verbose: print(f"Executing: {build_command}") @@ -77,9 +68,12 @@ def command(ctx, include, exclude): remove=True, interactive=True, tty=True, - envs={"NPM_AUTH_TOKEN": "6613572a28ebebaee20ccd90064251fa8c2b94f6"}, + user=f"{os.getuid()}:{os.getgid()}", + envs={"CERC_NPM_AUTH_TOKEN": os.environ["CERC_NPM_AUTH_TOKEN"]}, add_hosts=[("host.docker.internal", "host-gateway")], - volumes=[(repo_full_path, "/workspace")]) + volumes=[(repo_full_path, "/workspace")], + command=build_command + ) # TODO: check result in build_result.returncode print(f"Result is: {build_result}") else: diff --git a/app/data/npm-package-list.txt b/app/data/npm-package-list.txt index 6e0ead2..3adedb5 100644 --- a/app/data/npm-package-list.txt +++ b/app/data/npm-package-list.txt @@ -1 +1,4 @@ gem +laconic-sdk +debug +laconic-registry-cli diff --git a/container-build/cerc-builder-js/README.md b/container-build/cerc-builder-js/README.md index 865d39e..da784ef 100644 --- a/container-build/cerc-builder-js/README.md +++ b/container-build/cerc-builder-js/README.md @@ -12,6 +12,6 @@ it is possible to build packages manually by invoking `docker run` , for example ``` $ docker run --rm -it --add-host host.docker.internal:host-gateway \ -v ${HOME}/cerc/laconic-registry-cli:/workspace cerc/builder-js \ - sh -c 'cd /workspace && NPM_AUTH_TOKEN=6613572a28ebebaee20ccd90064251fa8c2b94f6 \ + sh -c 'cd /workspace && CERC_NPM_AUTH_TOKEN=6613572a28ebebaee20ccd90064251fa8c2b94f6 \ build-npm-package-local-dependencies.sh http://host.docker.internal:3000/api/packages/cerc-io/npm/ 0.1.8' ``` diff --git a/container-build/cerc-builder-js/build-npm-package.sh b/container-build/cerc-builder-js/build-npm-package.sh index 6161e23..88cc974 100755 --- a/container-build/cerc-builder-js/build-npm-package.sh +++ b/container-build/cerc-builder-js/build-npm-package.sh @@ -1,6 +1,6 @@ #!/bin/bash # Usage: build-npm-package.sh -# Note: supply the registry auth token in NPM_AUTH_TOKEN +# Note: supply the registry auth token in CERC_NPM_AUTH_TOKEN if [ -n "$CERC_SCRIPT_DEBUG" ]; then set -x fi @@ -8,15 +8,15 @@ if [[ $# -ne 2 ]]; then echo "Illegal number of parameters" >&2 exit 1 fi -if [[ -z "${NPM_AUTH_TOKEN}" ]]; then - echo "NPM_AUTH_TOKEN is not set" >&2 +if [[ -z "${CERC_NPM_AUTH_TOKEN}" ]]; then + echo "CERC_NPM_AUTH_TOKEN is not set" >&2 exit 1 fi local_npm_registry_url=$1 package_publish_version=$2 npm config set @lirewine:registry ${local_npm_registry_url} npm config set @cerc-io:registry ${local_npm_registry_url} -npm config set -- ${local_npm_registry_url}:_authToken ${NPM_AUTH_TOKEN} +npm config set -- ${local_npm_registry_url}:_authToken ${CERC_NPM_AUTH_TOKEN} echo "Build and publish version ${package_publish_version}" yarn install yarn build