Skip to content

Instantly share code, notes, and snippets.

@KemperVreden
Created March 2, 2017 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KemperVreden/84f78ecc31e64786784d560698c4522b to your computer and use it in GitHub Desktop.
Save KemperVreden/84f78ecc31e64786784d560698c4522b to your computer and use it in GitHub Desktop.
# base-image for python on any machine using a template variable,
# see more about dockerfile templates here:http://docs.resin.io/pages/deployment/docker-templates
FROM resin/%%RESIN_MACHINE_NAME%%-python:2.7
# Set our working directory
WORKDIR /usr/src/app
# -- Start of resin-wifi-connect section -- #
# Set the device type environment variable using Dockerfile templates
ENV DEVICE_TYPE=%%RESIN_MACHINE_NAME%%
# Use apt-get to install dependencies
RUN apt-get update && apt-get install -yq --no-install-recommends \
dnsmasq \
hostapd \
iproute2 \
iw \
libdbus-1-dev \
libexpat-dev \
rfkill && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Install node
ENV NODE_VERSION 6.9.1
RUN curl -SLO "http://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-armv6l.tar.gz" && \
echo "0b30184fe98bd22b859db7f4cbaa56ecc04f7f526313c8da42315d89fabe23b2 node-v6.9.1-linux-armv6l.tar.gz" | sha256sum -c - && \
tar -xzf "node-v$NODE_VERSION-linux-armv6l.tar.gz" -C /usr/local --strip-components=1 && \
rm "node-v$NODE_VERSION-linux-armv6l.tar.gz" && \
npm config set unsafe-perm true -g --unsafe-perm && \
rm -rf /tmp/*
# Install resin-wifi-connect
ENV RESIN_WIFI_CONNECT_VERSION v2.0.1
RUN git clone --branch $RESIN_WIFI_CONNECT_VERSION --depth 1 https://github.com/resin-io/resin-wifi-connect.git && \
cd resin-wifi-connect && \
JOBS=MAX npm install --unsafe-perm --production && \
npm cache clean && \
./node_modules/.bin/bower --allow-root install && \
./node_modules/.bin/bower --allow-root cache clean && \
./node_modules/.bin/coffee -c ./src
# -- End of resin-wifi-connect section -- #
# Use apt-get to install dependencies
RUN apt-get update && apt-get install -yq --no-install-recommends \
python-dev \
python-smbus \
python-psutil \
wireless-tools && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# ----- REGULAR ------ #
# here we install apt dependencies. We also remove the apt lists in the same step,
# this reduces the size of the docker image.
RUN apt-get update && apt-get install -yq --no-install-recommends \
openssh-server && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# here we set up the config for openSSH.
RUN mkdir /var/run/sshd \
&& echo 'root:resin' | chpasswd \
&& sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
&& sed -i 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config
# Copy requirements.txt first for better cache on later pushes
# COPY ./requirements.txt /requirements.txt
# pip install python deps from requirements.txt on the resin.io build server
RUN pip install spidev
RUN pip install py-opc
RUN pip install eventlet
RUN pip install flask
RUN pip install flask-socketio
RUN pip install pyserial
# This will copy all files in our root to the working directory in the container
COPY . ./
# switch on systemd init system in container
ENV INITSYSTEM on
# main.py will run when container starts up on the device
# CMD ["python","src/main.py"]
CMD ["./src/start.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment