From 7914cfad2c93b5627bba4c23d838fd8571980daf Mon Sep 17 00:00:00 2001 From: copyrights Date: Sun, 2 Jun 2019 21:29:36 +0200 Subject: [PATCH 01/10] create Dockerfile to build espurna with docker --- docker/Dockerfile | 41 +++++++++++++++++++++++++++++++++++++++++ docker/README.md | 0 2 files changed, 41 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000000..bdd14c5a9e --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,41 @@ +FROM debian:buster-slim + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update && apt-get upgrade -y && \ + apt-get install -y python2-minimal \ + python-pip \ + nodejs \ + npm \ + git \ + libc-bin \ + bash \ + && npm install -g npm \ + && pip install platformio + +RUN groupadd --gid 1000 worker && \ + useradd \ + --uid 1000 \ + --gid worker \ + --shell /bin/bash \ + --create-home worker + +RUN mkdir -p /espurna && \ + mkdir -p /firmware && \ + chown -R worker:worker /espurna && \ + chown -R worker:worker /firmware + +USER worker + +RUN git clone -b dev https://github.com/xoseperez/espurna.git /espurna && \ + cd /espurna/code && \ + npm install --only=dev && \ + platformio run --target clean + +VOLUME ["/espurna", "/firmware"] + +WORKDIR /espurna/code + +COPY docker-entrypoint.sh / +ENTRYPOINT ["./build.sh", "-d", "/firmware"] +CMD [] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000000..e69de29bb2 From 682d09aec95169a09a187f224d3f359b548d293c Mon Sep 17 00:00:00 2001 From: copyrights Date: Sun, 2 Jun 2019 22:52:35 +0200 Subject: [PATCH 02/10] write README.md --- docker/README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docker/README.md b/docker/README.md index e69de29bb2..a9ff0f0b4f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -0,0 +1,28 @@ +# Docker build image + +This directory contains a docker file for an ESPurna build environment. + +Two volumes can be used. +* `/espurna` with ESPurna source code. +* `/firmware` target directory for complied firmware files. + +## Build + +```bash +docker build -t espruna-build . +``` + +## Examples + +The simples example will build all firmware files from dev branch to /tmp/firmware. + +```bash +docker run --rm -it -v /tmp/firmware/:/firmware espruna-build +``` + + +This example will only build firmware for environment `intermittech-quinled` from local files in `/home/user/espurna` + +```bash +docker run --rm -it -v /tmp/firmware/:/firmware -v /home/user/espurna/:/espurna espruna-build intermittech-quinled +``` From a9561901786ebb6a778b8c7abc8a0548e5b045d6 Mon Sep 17 00:00:00 2001 From: copyrights Date: Sun, 2 Jun 2019 22:55:55 +0200 Subject: [PATCH 03/10] fix typo --- docker/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/README.md b/docker/README.md index a9ff0f0b4f..9d016d7a8c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -9,7 +9,7 @@ Two volumes can be used. ## Build ```bash -docker build -t espruna-build . +docker build -t espurna-build . ``` ## Examples @@ -17,12 +17,12 @@ docker build -t espruna-build . The simples example will build all firmware files from dev branch to /tmp/firmware. ```bash -docker run --rm -it -v /tmp/firmware/:/firmware espruna-build +docker run --rm -it -v /tmp/firmware/:/firmware espurna-build ``` This example will only build firmware for environment `intermittech-quinled` from local files in `/home/user/espurna` ```bash -docker run --rm -it -v /tmp/firmware/:/firmware -v /home/user/espurna/:/espurna espruna-build intermittech-quinled +docker run --rm -it -v /tmp/firmware/:/firmware -v /home/user/espurna/:/espurna espurna-build intermittech-quinled ``` From 9084848b83a00d10699b0af2dbe3c0e7f363862e Mon Sep 17 00:00:00 2001 From: copyrights Date: Sun, 2 Jun 2019 23:30:07 +0200 Subject: [PATCH 04/10] change Dockerfile to fix automated code review --- docker/Dockerfile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index bdd14c5a9e..105313dfb2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,14 +2,19 @@ FROM debian:buster-slim ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && apt-get upgrade -y && \ - apt-get install -y python2-minimal \ +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + python2-minimal \ python-pip \ + python-setuptools \ + ca-certificates \ nodejs \ npm \ git \ libc-bin \ bash \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ && npm install -g npm \ && pip install platformio @@ -27,15 +32,14 @@ RUN mkdir -p /espurna && \ USER worker -RUN git clone -b dev https://github.com/xoseperez/espurna.git /espurna && \ - cd /espurna/code && \ - npm install --only=dev && \ +RUN git clone -b dev https://github.com/xoseperez/espurna.git /espurna + +WORKDIR /espurna/code + +RUN npm install --only=dev && \ platformio run --target clean VOLUME ["/espurna", "/firmware"] -WORKDIR /espurna/code - -COPY docker-entrypoint.sh / ENTRYPOINT ["./build.sh", "-d", "/firmware"] CMD [] From a35ddad3598477778d408030c3b4fe8cc1c25d2a Mon Sep 17 00:00:00 2001 From: copyrights Date: Sun, 2 Jun 2019 23:54:42 +0200 Subject: [PATCH 05/10] add version pinning --- docker/Dockerfile | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 105313dfb2..59e1ba2069 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,24 +4,22 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get update \ && apt-get install -y --no-install-recommends \ - python2-minimal \ - python-pip \ - python-setuptools \ - ca-certificates \ - nodejs \ - npm \ - git \ - libc-bin \ - bash \ + python2-minimal=2.7.16-1 \ + python-pip=18.1-5 \ + python-setuptools=40.8.0-1 \ + ca-certificates=20190110 \ + nodejs=10.15.2~dfsg-2 \ + npm=5.8.0+ds6-4 \ + git=1:2.20.1-2 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* \ && npm install -g npm \ - && pip install platformio + && pip install platformio==3.6.7 RUN groupadd --gid 1000 worker && \ useradd \ --uid 1000 \ - --gid worker \ + --gid worker \ --shell /bin/bash \ --create-home worker From 6541c295e353436320489f4d29a17520db209b42 Mon Sep 17 00:00:00 2001 From: copyrights Date: Mon, 3 Jun 2019 20:58:21 +0200 Subject: [PATCH 06/10] redice version pinning; remove apt-get clean --- docker/Dockerfile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 59e1ba2069..f1cfc0fc3a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,17 +4,16 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get update \ && apt-get install -y --no-install-recommends \ - python2-minimal=2.7.16-1 \ - python-pip=18.1-5 \ - python-setuptools=40.8.0-1 \ - ca-certificates=20190110 \ - nodejs=10.15.2~dfsg-2 \ - npm=5.8.0+ds6-4 \ - git=1:2.20.1-2 \ - && apt-get clean \ + python2-minimal \ + python-pip \ + python-setuptools \ + ca-certificates \ + nodejs \ + npm \ + git \ && rm -rf /var/lib/apt/lists/* \ && npm install -g npm \ - && pip install platformio==3.6.7 + && pip install "platformio>=3.6,<3.7" RUN groupadd --gid 1000 worker && \ useradd \ From 861016478cb6e55c18ad872adc901b8f4d843be1 Mon Sep 17 00:00:00 2001 From: copyrights Date: Mon, 3 Jun 2019 21:46:27 +0200 Subject: [PATCH 07/10] use COPY instead of git clone --- docker/Dockerfile | 4 ++-- docker/README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f1cfc0fc3a..f99cee7883 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -27,9 +27,9 @@ RUN mkdir -p /espurna && \ chown -R worker:worker /espurna && \ chown -R worker:worker /firmware -USER worker +COPY --chown=worker:worker . /espurna -RUN git clone -b dev https://github.com/xoseperez/espurna.git /espurna +USER worker WORKDIR /espurna/code diff --git a/docker/README.md b/docker/README.md index 9d016d7a8c..215663624b 100644 --- a/docker/README.md +++ b/docker/README.md @@ -9,7 +9,7 @@ Two volumes can be used. ## Build ```bash -docker build -t espurna-build . +docker build -t espurna-build -f Dockerfile .. ``` ## Examples From a0647893bb67b4122d1c36421976526c169bf579 Mon Sep 17 00:00:00 2001 From: copyrights Date: Tue, 4 Jun 2019 09:50:05 +0200 Subject: [PATCH 08/10] fix typo --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 215663624b..779ad2e6b6 100644 --- a/docker/README.md +++ b/docker/README.md @@ -14,7 +14,7 @@ docker build -t espurna-build -f Dockerfile .. ## Examples -The simples example will build all firmware files from dev branch to /tmp/firmware. +This simple example will build all firmware files from dev branch to /tmp/firmware. ```bash docker run --rm -it -v /tmp/firmware/:/firmware espurna-build From 246b4ca1de6a85dc5c097c756f5275efe0ced5f4 Mon Sep 17 00:00:00 2001 From: copyrights Date: Tue, 4 Jun 2019 10:19:38 +0200 Subject: [PATCH 09/10] make UID and GID configurable --- docker/Dockerfile | 7 +++++-- docker/README.md | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index f99cee7883..be246e4024 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -15,9 +15,12 @@ RUN apt-get update \ && npm install -g npm \ && pip install "platformio>=3.6,<3.7" -RUN groupadd --gid 1000 worker && \ +ARG UID=1000 +ARG GID=1000 + +RUN groupadd --gid $GID worker && \ useradd \ - --uid 1000 \ + --uid $UID \ --gid worker \ --shell /bin/bash \ --create-home worker diff --git a/docker/README.md b/docker/README.md index 779ad2e6b6..25bf25d2af 100644 --- a/docker/README.md +++ b/docker/README.md @@ -9,7 +9,7 @@ Two volumes can be used. ## Build ```bash -docker build -t espurna-build -f Dockerfile .. +docker build -t espurna-build --build-arg UID=$(id -u) --build-arg GID=$(id -g) -f Dockerfile .. ``` ## Examples From 9c111607a3c55a4911e8f903327ebefe0a327276 Mon Sep 17 00:00:00 2001 From: copyrights Date: Tue, 4 Jun 2019 10:29:00 +0200 Subject: [PATCH 10/10] add .dockerignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ```diff diff .gitignore .dockerignore 10,13d9 < credentials.h < node_modules < code/utils < custom.h ยดยดยด --- .dockerignore | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..2e03ddc8b7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +*.s#? +*.b#? +.modgit +firmware* +*.gch +.pio* +.clang_complete +.gcc-flags.json +.sconsign.dblite +.python +.env +.DS_Store +.vscode