8 changed files with 124 additions and 37 deletions
@ -1,18 +1,29 @@ |
|||
FROM resin/%%RESIN_MACHINE_NAME%%-buildpack-deps |
|||
FROM resin/%%RESIN_MACHINE_NAME%%-debian:latest AS buildstep |
|||
|
|||
# Enable systemd, as Resin requires this |
|||
ENV INITSYSTEM on |
|||
WORKDIR /opt/ttn-gateway/ |
|||
|
|||
# Make the hardware type available as a runtime env var |
|||
ENV RESIN_ARCH %%RESIN_ARCH%% |
|||
ENV RESIN_MACHINE_NAME %%RESIN_MACHINE_NAME%% |
|||
# downloading utils |
|||
RUN apt-get update && \ |
|||
apt-get install wget build-essential libc6-dev git pkg-config protobuf-compiler libprotobuf-dev libprotoc-dev automake libtool autoconf python-dev python-rpi.gpio |
|||
|
|||
# Copy the build and run environment |
|||
COPY . /opt/ttn-gateway/ |
|||
WORKDIR /opt/ttn-gateway/ |
|||
COPY dev dev |
|||
RUN ./dev/build.sh |
|||
|
|||
FROM resin/%%RESIN_MACHINE_NAME%%-debian:latest |
|||
|
|||
WORKDIR /opt/ttn-gateway |
|||
|
|||
RUN apt-get update && \ |
|||
apt-get install python-rpi.gpio && \ |
|||
apt-get clean && \ |
|||
rm -rf /var/lib/apt/lists/* |
|||
|
|||
COPY --from=buildstep /opt/ttn-gateway/mp_pkt_fwd . |
|||
COPY --from=buildstep /usr/local/lib/libpaho-embed-* /usr/lib/ |
|||
COPY --from=buildstep /usr/lib/libttn* /usr/lib/ |
|||
|
|||
# Build the gateway (or comment this out if debugging on-device) |
|||
RUN ./dev/build.sh && rm -rf ./dev |
|||
COPY run.py ./ |
|||
COPY start.sh ./ |
|||
|
|||
# Start it up |
|||
CMD ["sh", "-c", "./run.py"] |
|||
# run when container lands on device |
|||
CMD ["bash", "start.sh"] |
|||
|
@ -0,0 +1,58 @@ |
|||
FROM resin/%%RESIN_MACHINE_NAME%%-debian:latest AS buildstep |
|||
|
|||
# downloading utils |
|||
RUN apt-get update && \ |
|||
apt-get install wget build-essential libc6-dev git pkg-config protobuf-compiler libprotobuf-dev libprotoc-dev automake libtool autoconf python-dev python-rpi.gpio |
|||
|
|||
WORKDIR /etc |
|||
|
|||
# versions |
|||
ENV NODE_EXPORTER_VERSION 0.12.0 |
|||
ENV DIST_ARCH linux-armv7 |
|||
RUN wget https://github.com/prometheus/node_exporter/releases/download/${NODE_EXPORTER_VERSION}/node_exporter-${NODE_EXPORTER_VERSION}.${DIST_ARCH}.tar.gz \ |
|||
&& tar xvfz node_exporter-${NODE_EXPORTER_VERSION}.${DIST_ARCH}.tar.gz \ |
|||
&& rm node_exporter-${NODE_EXPORTER_VERSION}.${DIST_ARCH}.tar.gz |
|||
|
|||
COPY gwexporter.tgz /opt/ttn-gateway/gwexporter.tgz |
|||
WORKDIR /opt/gwexporter |
|||
RUN tar xvzf /opt/ttn-gateway/gwexporter.tgz |
|||
RUN wget https://nodejs.org/dist/v8.8.1/node-v8.8.1-linux-armv6l.tar.gz \ |
|||
&& tar xvzf node-v8.8.1-linux-armv6l.tar.gz \ |
|||
&& mv node-v8.8.1-linux-armv6l/* . \ |
|||
&& rm -rf node-v8.8.1-linux-armv6l |
|||
|
|||
WORKDIR /opt/ttn-gateway/ |
|||
COPY dev dev |
|||
RUN ./dev/build.sh |
|||
|
|||
FROM resin/%%RESIN_MACHINE_NAME%%-debian:latest |
|||
RUN apt-get update && \ |
|||
apt-get install python-rpi.gpio && \ |
|||
apt-get clean && \ |
|||
rm -rf /var/lib/apt/lists/* |
|||
|
|||
# Enable systemd |
|||
ENV INITSYSTEM on |
|||
|
|||
# versions |
|||
ENV NODE_EXPORTER_VERSION 0.12.0 |
|||
ENV DIST_ARCH linux-armv7 |
|||
|
|||
WORKDIR /etc |
|||
COPY --from=buildstep /etc/node_exporter-${NODE_EXPORTER_VERSION}.${DIST_ARCH} . |
|||
|
|||
WORKDIR /opt/gwexporter |
|||
COPY --from=buildstep /opt/gwexporter . |
|||
|
|||
WORKDIR /opt/ttn-gateway |
|||
COPY --from=buildstep /opt/ttn-gateway/mp_pkt_fwd . |
|||
COPY --from=buildstep /usr/local/lib/libpaho-embed-* /usr/lib/ |
|||
COPY --from=buildstep /usr/lib/libttn* /usr/lib/ |
|||
COPY run.py run.py |
|||
|
|||
WORKDIR / |
|||
|
|||
COPY start.sh.metering start.sh |
|||
|
|||
# run when container lands on device |
|||
CMD ["bash", "start.sh"] |
Binary file not shown.
@ -0,0 +1,3 @@ |
|||
#!/bin/bash |
|||
|
|||
python /opt/ttn-gateway/run.py |
@ -0,0 +1,15 @@ |
|||
#!/bin/bash |
|||
|
|||
# Start the node exporter |
|||
mkdir /mnt/ramdisk |
|||
mount -t tmpfs -o size=8m tmpfs /mnt/ramdisk |
|||
cd /mnt/ramdisk |
|||
/opt/ttn-gateway/run.py & |
|||
|
|||
# WORKAROUND: Add symlink, as gwexporter otherwise currently don't seem to find this file |
|||
ln -s /mnt/ramdisk/loragwstat.json /opt/gwexporter/loragwstat.json |
|||
|
|||
export PATH=$PATH:/opt/gwexporter/bin |
|||
node /opt/gwexporter/gwexporter.js & |
|||
|
|||
cd /etc && ./node_exporter -web.listen-address ":81" |
Loading…
Reference in new issue