Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A dockerfile for building the Azure IoT-Edge Gateway in a container.
FROM ubuntu
# ENV vars for setup
ENV IoTHubName {iot_hub_name}
ENV IoTHubSuffix azure-devices.net
ENV device1 {device1_name}
ENV device1key {device1_key}
ENV device2 {device2_name}
ENV device2key {device2_key}
# Update image
RUN apt-get update
RUN apt-get --assume-yes 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'"' \
# set device 1 message period
| jq '.modules[2].args.messagePeriod=10000' \
# set device 2 message period
| jq '.modules[3].args.messagePeriod=10000' \
> replaced.json \
# print updates
&& cat replaced.json \
# cd back up to build dir
&& cd /usr/src/app/iot-edge/build/ \
# run gateway
&& ./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