Skip to content

Instantly share code, notes, and snippets.

@WilliamBerryiii
Last active May 2, 2019 01:40
Show Gist options
  • Save WilliamBerryiii/681fe3b42001d7251051984ad24cf01a to your computer and use it in GitHub Desktop.
Save WilliamBerryiii/681fe3b42001d7251051984ad24cf01a to your computer and use it in GitHub Desktop.
Dockerfile Example for Resin.io to build & run Azure IoT-Edge Gateway
FROM resin/raspberrypi3-node
ENV INITSYSTEM=on
# Update image
RUN apt-get update
RUN apt-get install curl build-essential libcurl4-openssl-dev git cmake pkg-config libssl-dev uuid-dev valgrind jq libglib2.0-dev libtool autoconf autogen vim
# Checkout code
WORKDIR /usr/src/app
RUN git clone https://github.com/Azure/iot-edge.git
# Build
WORKDIR /usr/src/app/iot-edge/tools
RUN ./build.sh --disable-native-remote-modules
# RUN
WORKDIR /usr/src/app/iot-edge/build
## cat config file into env var
ENTRYPOINT J_FILE=$(cat /usr/src/app/iot-edge/samples/simulated_device_cloud_upload/src/simulated_device_cloud_upload_lin.json) \
# cd into sample dir
&& cd /usr/src/app/iot-edge/samples/simulated_device_cloud_upload/src/ \
# update settings based on env vars
&& echo "$J_FILE" \
#configure iot hub
| jq '.modules[0].args.IoTHubName="'$IoTHubName'"' \
| jq '.modules[0].args.IoTHubSuffix="'$IoTHubSuffix'"' \
| jq '.modules[0].args.Transport="AMQP"' \
# configure device 1
| jq '.modules[1].args[0].deviceId="'$device1'"' \
| jq '.modules[1].args[0].deviceKey="'$device1key'"' \
# configure device 2
| jq '.modules[1].args[1].deviceId="'$device2'"' \
| jq '.modules[1].args[1].deviceKey="'$device2key'"' \
# uncomment the following line to set device 1 message period
#| jq '.modules[2].args.messagePeriod=30000' \
# uncomment the following line to set device 2 message period
#| jq '.modules[3].args.messagePeriod=30000' \
# save changes
> replaced.json \
# cd back up to build dir
&& cd /usr/src/app/iot-edge/build/ \
# run gateway with new config file
&& ./samples/simulated_device_cloud_upload/simulated_device_cloud_upload_sample ../samples/simulated_device_cloud_upload/src/replaced.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment