I'm doing something I thought was simple:
# Fetch config
- name: 'gcr.io/cloud-builders/gsutil'
volumes:
- name: 'vol1'
path: '/persistent_volume'
args: [ 'cp', 'gs://servicesconfig/devs/react-app/env.server', '/persistent_volume/env.server' ]
# Install dependencies
- name: node:$_NODE_VERSION
entrypoint: 'yarn'
args: [ 'install' ]
# Build project
- name: node:$_NODE_VERSION
volumes:
- name: 'vol1'
path: '/persistent_volume'
entrypoint: 'bash'
args:
- -c
- |
cp /persistent_volume/env.server .env.production &&
cat .env.production &&
ls -la &&
yarn run build:prod
while in my package.json:
"build:prod": "sh -ac '. .env.production; react-scripts build'",
All of this works well in local but the output in gcp cloud build:
Already have image: node:14
REACT_APP_ENV="sandbox"
REACT_APP_CAPTCHA_ENABLED=true
REACT_APP_CAPTCHA_PUBLIC_KEY="akey"
REACT_APP_DEFAULT_APP="home-btn"
REACT_APP_API_URL="akey2"
REACT_APP_STRIPE_KEY="akey3"
REACT_APP_COGNITO_POOL_ID="akey4"
REACT_APP_COGNITO_APP_ID="akey5"
total 2100
drwxr-xr-x 6 root root 4096 Feb 25 12:15 .
drwxr-xr-x 1 root root 4096 Feb 25 12:15 ..
-rw-r--r-- 1 root root 382 Feb 25 12:15 .env.production <- it's here!
drwxr-xr-x 8 root root 4096 Feb 25 12:13 .git
-rw-r--r-- 1 root root 230 Feb 25 12:13 .gitignore
-rw-r--r-- 1 root root 371 Feb 25 12:13 Dockerfile
-rw-r--r-- 1 root root 3787 Feb 25 12:13 README.md
-rw-r--r-- 1 root root 1019 Feb 25 12:13 cloudbuild.yaml
drwxr-xr-x 1089 root root 36864 Feb 25 12:14 node_modules
-rw-r--r-- 1 root root 1580131 Feb 25 12:13 package-lock.json
-rw-r--r-- 1 root root 1896 Feb 25 12:13 package.json
drwxr-xr-x 2 root root 4096 Feb 25 12:13 public
drwxr-xr-x 9 root root 4096 Feb 25 12:13 src
-rw-r--r-- 1 root root 535 Feb 25 12:13 tsconfig.json
-rw-r--r-- 1 root root 478836 Feb 25 12:13 yarn.lock
/workspace
yarn run v1.22.17
$ sh -ac '. .env.production; react-scripts build'
sh: 1: .: .env.production: not found
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I'm unsure if I'm doing something completely wrong or if it's a bug on GCP side?