Last active
November 25, 2021 08:51
-
-
Save michaelact/cab52dd8935be028689896ecc49c1633 to your computer and use it in GitHub Desktop.
Install NPM package from artifact registry inside Container Image | Must be have Service Account file!
This file contains 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
#!/bin/bash | |
set -e | |
gcloud auth activate-service-account \ | |
--project=$GCP_PROJECT \ | |
--key-file=${GCP_KEY_FILENAME:-service_account.json} | |
gcloud artifacts print-settings npm \ | |
--project=$GCP_PROJECT \ | |
--scope=$PACKAGE_SCOPE \ | |
--repository=$PACKAGE_REPOSITORY \ | |
--location=$PACKAGE_LOCATION > .npmrc | |
curl -sLfo /tmp/setup.sh https://deb.nodesource.com/setup_12.x \ | |
&& chmod +x /tmp/setup.sh \ | |
&& /tmp/setup.sh \ | |
&& rm -fr /tmp/setup.sh \ | |
&& apt-get install nodejs \ | |
&& rm -fr /var/lib/apt/lists/* | |
npx google-artifactregistry-auth | |
npm ci |
This file contains 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
version: '3.8' | |
services: | |
builder: | |
image: gcr.io/cloud-builders/gcloud | |
entrypoint: /bin/bash | |
command: bash -c ./build.sh | |
working_dir: /tmp/frontend-utils | |
# Set the environment variables below from your host machine | |
# Or set variable value inside this file following https://docs.docker.com/compose/environment-variables/#set-environment-variables-in-containers | |
environment: | |
- GCP_PROJECT | |
- GCP_KEY_FILENAME | |
- PACKAGE_SCOPE | |
- PACKAGE_REPOSITORY | |
- PACKAGE_LOCATION | |
volumes: | |
- .:/tmp/frontend-utils |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment