Skip to content

Instantly share code, notes, and snippets.

@WilliamBerryiii
Created June 13, 2017 23:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WilliamBerryiii/ee31a154d99130f9bbe472a320d49655 to your computer and use it in GitHub Desktop.
Save WilliamBerryiii/ee31a154d99130f9bbe472a320d49655 to your computer and use it in GitHub Desktop.
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