From 318d70020e15bcd411d58e68fd2c366e7cd46ab7 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 6 Jan 2023 13:54:03 -0700 Subject: [PATCH] Add build environment --- app/build_containers.py | 6 ++++++ container-build/cerc-laconic-registry-cli/Dockerfile | 12 ++++++------ container-build/cerc-laconic-registry-cli/build.sh | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/build_containers.py b/app/build_containers.py index f8edb0b3..43888b3d 100644 --- a/app/build_containers.py +++ b/app/build_containers.py @@ -64,6 +64,12 @@ def command(ctx, include, exclude): if verbose: print(f'Containers: {containers}') + # TODO: make this configurable + container_build_env = { + "CERC_NPM_URL": "http://host.docker.internal:3000/api/packages/cerc-io/npm/", + "CERC_NPM_AUTH_TOKEN": os.environ["CERC_NPM_AUTH_TOKEN"] + } + def process_container(container): if not quiet: print(f"Building: {container}") diff --git a/container-build/cerc-laconic-registry-cli/Dockerfile b/container-build/cerc-laconic-registry-cli/Dockerfile index 45ec0a8c..ba22a5c9 100644 --- a/container-build/cerc-laconic-registry-cli/Dockerfile +++ b/container-build/cerc-laconic-registry-cli/Dockerfile @@ -7,8 +7,8 @@ ARG USERNAME=node ARG NPM_GLOBAL=/usr/local/share/npm-global # This container pulls npm packages from a local registry configured via these env vars -ARG CERC_LOCAL_NPM_URL -ARG CERC_LOCAL_NPM_TOKEN +ARG CERC_NPM_URL +ARG CERC_NPM_AUTH_TOKEN # Add NPM global to PATH. ENV PATH=${NPM_GLOBAL}/bin:${PATH} @@ -40,10 +40,10 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # RUN su node -c "npm install -g " # Configure the local npm registry -RUN npm config set @lirewine:registry ${CERC_LOCAL_NPM_URL} \ - && npm config set @cerc-io:registry ${CERC_LOCAL_NPM_URL} \ - && npm config set @lirewine:registry ${CERC_LOCAL_NPM_URL} \ - && npm config set -- ${CERC_LOCAL_NPM_URL}:_authToken ${CERC_LOCAL_NPM_TOKEN} +RUN npm config set @lirewine:registry ${CERC_NPM_URL} \ + && npm config set @cerc-io:registry ${CERC_NPM_URL} \ + && npm config set @lirewine:registry ${CERC_NPM_URL} \ + && npm config set -- ${CERC_NPM_URL}:_authToken ${CERC_NPM_AUTH_TOKEN} # TODO: the image at this point could be made a base image for several different CLI images # that install different Node-based CLI commands diff --git a/container-build/cerc-laconic-registry-cli/build.sh b/container-build/cerc-laconic-registry-cli/build.sh index 43ec55a7..fa29fa4b 100755 --- a/container-build/cerc-laconic-registry-cli/build.sh +++ b/container-build/cerc-laconic-registry-cli/build.sh @@ -6,4 +6,4 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) docker build -t cerc/laconic-registry-cli:local -f ${SCRIPT_DIR}/Dockerfile \ --add-host host.docker.internal:host-gateway \ - --build-arg CERC_LOCAL_NPM_TOKEN --build-arg CERC_LOCAL_NPM_URL ${SCRIPT_DIR} + --build-arg CERC_NPM_AUTH_TOKEN --build-arg CERC_NPM_URL ${SCRIPT_DIR}