PlatformIO Community

Compiling espressif32 in Docker on GCP Cloud Run

Hello all!

Goal - I am trying to automate provisioning the bin.
I want to host a Google Cloud Run container that can generate parameters needed for Google IoT and pass those to Platformio to compile into the binary (such as device id and private key) and copy to a storage bucket so I can later write to an ESP32.

I have a working Dockerfile that installs python and Platformio, installs nodejs (acts as the webserver), and a shell script that exports environment variables which then calls platformio run.

This process works locally, I make a POST to my container and it WORKS. I can take the created bin files and write them to the ESP32 and it works. This ALSO works in GKE as a deployment. I call it the same way. My issue is in Cloud Run I get this error:
image

Any thoughts on what the issue is (Unknown development environment) or where to properly categorize this issue? I’ve tried these steps but haven’t found any useful debug information. I was going to try StackOverflow and a GCP forum next. Thanks a lot!

Platform.ini

[env:featheresp32]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
upload_port = /dev/cu.SLAB_USBtoUART
monitor_port = /dev/cu.SLAB_USBtoUART
build_flags = 
	'-DDEVICE_ID="${sysenv.DEVICE_ID}"'
	'-DPROJECT_ID="${sysenv.PROJECT_ID}"'
	'-DPROJECT_LOCATION="${sysenv.PROJECT_LOCATION}"'
	'-DREGISTRY_ID="${sysenv.REGISTRY_ID}"'
	'-DPRIVATE_KEY="${sysenv.PRIVATE_KEY}"'
lib_deps = 
	...

Dockerfile

FROM node:14
WORKDIR /usr/src/app

# platformio executable via python doesn't change much. Put it at the beginning to cache off this layer
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
RUN apt-get update && apt-get install python3 python3-pip -y
RUN pip3 install -U platformio

# Doesn't change a whole lot right now copy code then install dependencies
COPY new-hardware/lib new-hardware/lib
COPY new-hardware/src new-hardware/src
COPY new-hardware/platformio.ini new-hardware/platformio.ini

WORKDIR /usr/src/app/rom-creator
COPY src/rom-creator/package*.json ./
RUN yarn install --production

COPY src/rom-creator/src/*.ts ./src/
COPY src/rom-creator/tsconfig.json ./
COPY src/rom-creator/create.sh ./
RUN node_modules/.bin/tsc

EXPOSE 8080
CMD [ "node", "dist/index.js" ]

Shell Script

#!/bin/bash

export DEVICE_ID="$1"
export PROJECT_ID="test-55555"
export PROJECT_LOCATION="us-central1"
export REGISTRY_ID="my-registry"
export PRIVATE_KEY="$2"

echo "using this device_id: $DEVICE_ID"
echo "using this private_key: $PRIVATE_KEY"
echo "$REGISTRY_ID"

cd /usr/src/app/new-hardware

platformio update
platformio run -v

Hm the only thing I can remember in regards to this error was maybe related to an issue where Arduino-ESP32 builds were broken and then fixed by https://github.com/espressif/arduino-esp32/pull/4307 which manipulates the platform.json by declaring the version to be '*' and removing the owner field… Might be totally unrelated though.

I think either @ivankravets or @valeros should have a look at that.