Skip to content

Commit

Permalink
Docker: Faster build time: Fetch pre-compiled toolchain instead of co…
Browse files Browse the repository at this point in the history
…mpilin… (#955)

* Faster build time: Fetch pre-compiled toolchain instead of compiling your own.
* SDK 2.0: Using Espressif's stock SDK 2.0.
* Simplified usage and generation.
* Added simple welcome screen with the next steps.
  • Loading branch information
slaff committed Feb 16, 2017
1 parent a7766da commit fbc0663
Show file tree
Hide file tree
Showing 8 changed files with 377 additions and 185 deletions.
163 changes: 11 additions & 152 deletions docker/Dockerfile
@@ -1,156 +1,15 @@
FROM phusion/baseimage:0.9.18
# ------------------------------------
# Fast dockerized development environment
# for the Sming Framework: https://github.com/SmingHub/Sming.git
# ------------------------------------
FROM attachix/c9-esp8266-sdk:latest
MAINTAINER Slavey Karadzhov <slav@attachix.com>

# ------------------------------------------------------------------------------
# Install Dependencies
# ------------------------------------------------------------------------------
COPY assets/welcome.html /cloud9/plugins/c9.ide.welcome/welcome.html
COPY assets/welcome.js /cloud9/plugins/c9.ide.welcome/welcome.js

RUN apt-get update && \
apt-get install -y make \
wget \
unrar \
autoconf \
automake \
libtool \
gcc \
g++ \
gperf \
flex \
bison \
texinfo \
gawk \
ncurses-dev \
libexpat-dev \
python \
python-dev \
python-serial \
sed \
git \
unzip \
bash \
wget \
bzip2 \
vim \
screen \
sudo \
help2man \
curl
RUN cd /workspace && git clone https://github.com/SmingHub/Sming.git

# ------------------------------------------------------------------------------
# Install Node
# ------------------------------------------------------------------------------
ENV SMING_HOME /workspace/Sming/Sming


RUN set -ex \
&& for key in \
9554F04D7259F04124DE6B476D5A82AC7E37093B \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
; do \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done

ENV NPM_CONFIG_LOGLEVEL info
ENV NODE_VERSION 4.4.3

RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz"
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc"
RUN gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc
RUN grep " node-v$NODE_VERSION-linux-x64.tar.xz\$" SHASUMS256.txt | sha256sum -c -
RUN tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1
RUN rm "node-v$NODE_VERSION-linux-x64.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt


# ------------------------------------------------------------------------------
# Install Cloud9
# ------------------------------------------------------------------------------

RUN git clone https://github.com/c9/core.git /opt/cloud9 && cd /opt/cloud9 && git checkout 32fc12bf922288d0c2b518c73aa75e19f14bed8b
WORKDIR /opt/cloud9
RUN scripts/install-sdk.sh
RUN npm install

# ------------------------------------------------------------------------------
# Tweak standlone.js conf
# ------------------------------------------------------------------------------

RUN sed -i -e 's_127.0.0.1_0.0.0.0_g' /opt/cloud9/configs/standalone.js

# ------------------------------------------------------------------------------
# Install Supervisor.
# ------------------------------------------------------------------------------

RUN apt-get install -y supervisor
RUN sed -i 's/^\(\[supervisord\]\)$/\1\nnodaemon=true/' /etc/supervisor/supervisord.conf

# ------------------------------------------------------------------------------
# Add supervisord configs
# ------------------------------------------------------------------------------

ADD conf/* /etc/supervisor/conf.d/

# ------------------------------------------------------------------------------
# Clean up APT when done.
# ------------------------------------------------------------------------------

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# ------------------------------------------------------------------------------
# Install ESP8266 SDK
# ------------------------------------------------------------------------------

RUN useradd -d /home/espbuilder -m espbuilder && \
usermod -a -G dialout espbuilder && \
mkdir -p /etc/sudoers.d && \
echo "espbuilder ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/espbuilder && \
chmod 0440 /etc/sudoers.d/espbuilder

RUN cd /opt && git clone --recursive https://github.com/pfalcon/esp-open-sdk.git && cd /opt/esp-open-sdk && git checkout e8d757b1a70a5cf19df0afe23a769739c6cff343
RUN chmod 777 -R /opt/esp-open-sdk

USER espbuilder
RUN cd /opt/esp-open-sdk && make VENDOR_SDK=1.5.4 STANDALONE=y

USER root

# ------------------------------------------------------------------------------
# Cleanup
# ------------------------------------------------------------------------------

RUN rm -rf /home/espbuilder/esp-open-sdk/crosstool-NG/.build

# ------------------------------------------------------------------------------
# Set Environment
# ------------------------------------------------------------------------------

ENV PATH /opt/esp-open-sdk/xtensa-lx106-elf/bin:$PATH
ENV XTENSA_TOOLS_ROOT /opt/esp-open-sdk/xtensa-lx106-elf/bin
ENV SDK_BASE /opt/esp-open-sdk/sdk
ENV FW_TOOL /opt/esp-open-sdk/xtensa-lx106-elf/bin/esptool.py

ENV ESP_HOME /opt/esp-open-sdk
ENV SMING_HOME /opt/sming/Sming

# ------------------------------------------------------------------------------
# Install esptool.py
# ------------------------------------------------------------------------------

RUN wget https://github.com/themadinventor/esptool/archive/master.zip && unzip master.zip && mv esptool-master $ESP_HOME/esptool && rm master.zip

# ------------------------------------------------------------------------------
# Install esptool2
# ------------------------------------------------------------------------------

RUN cd $ESP_HOME && git clone https://github.com/raburton/esptool2 && cd $ESP_HOME/esptool2 && git checkout ec0e2c72952f4fa8242eedd307c58a479d845abe
RUN cd $ESP_HOME/esptool2 && make

ENV PATH $ESP_HOME/esptool2:$PATH


EXPOSE 80

CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]
ENTRYPOINT /usr/bin/supervisord
62 changes: 62 additions & 0 deletions docker/README.md
@@ -0,0 +1,62 @@
## Install docker

Visit the official [Docker Installation Page](https://docs.docker.com/engine/installation/) and follow the instructions tailored for your operating system.

## Install docker-compose

Docker Compose makes dealing with the orchestration processes of Docker containers (such as starting up, shutting down, and setting up intra-container linking and volumes) really easy.

With docker compose we can define the entire multi-container application in single file and then the application can be spinned up using one command.

Visit the official [Docker Compose Installation Page](https://docs.docker.com/compose/install/) and follow the instructions tailored for your operating system.

## (Optional) Adjust your setting

Edit the docker-compose.yml and adjust the settings, if needed.

```
# Uncomment the lines below if you want to map your local source code
# inside the docker container
# volumes:
# - ../../Sming/:/workspace/Sming
ports:
#choose a free port to connect to the web C9 editor
- "10080:80"
devices:
# uncomment to map your serial USB adaptor
#- "/dev/ttyUSB0:/dev/ttyUSB0"
```

## Start your container

```shell
docker-compose up -d
```
## Open your browser

http://localhost:10080

[![C9 screenshot example](images/c9-1.png)](images/c9-1.png)

And inside of the Terminal tab in your browser window you can type

```shell
cd $SMING_HOME
make
```

```shell
cd $SMING_HOME/../samples/Basic_Blink
make
make flash
```

## Shut down your container

```shell
docker-compose down
```
39 changes: 39 additions & 0 deletions docker/assets/welcome.html
@@ -0,0 +1,39 @@
<div class="welcome">
<div class="main">
<div class="welcome-heading">Welcome</div>
<div class="intro">
</div>

<div class="next">
Welcome to the simplified Sming development environment. If you look on the left side you will see a workspace pane.
Under workscpace/Sming/samples you will find all available examples that will get you started.
If you want to compile your first project we recommend you to try the Basic_Blink project.
To do this go to the <a href="#" class="openterminal">terminal window</a> and type in there:
<pre>
cd $SMING_HOME/../samples/Basic_Blink
make
</pre>

Once the compilation has finished you can upload your program on your ESP8266 device. Make sure that the
device is connect to your computer on /dev/ttyUSB0 and type:
<pre>
make flash
</pre>
</div>
</div>

<div class="sidepanel">
<h3>Docs</h3>
<div class="article">
<h4><a href="https://sminghub.github.io/Sming/api/" target="_blank">API documentations</a></h4>
<p>This is the documentation for the API of Sming - a C++ framework for development on the ESP8266 microcontroller platform.</p>
</div>

<div class="article">
<h4><a href="https://github.com/SmingHub/Sming/wiki" target="_blank">Wiki</a></h4>
<p>Short introductory articles can be find in our Wik.</p>
</div>

<br /><br />
</div>
</html>

0 comments on commit fbc0663

Please sign in to comment.