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 diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000000..be246e4024 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,45 @@ +FROM debian:buster-slim + +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 \ + && rm -rf /var/lib/apt/lists/* \ + && npm install -g npm \ + && pip install "platformio>=3.6,<3.7" + +ARG UID=1000 +ARG GID=1000 + +RUN groupadd --gid $GID worker && \ + useradd \ + --uid $UID \ + --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 + +COPY --chown=worker:worker . /espurna + +USER worker + +WORKDIR /espurna/code + +RUN npm install --only=dev && \ + platformio run --target clean + +VOLUME ["/espurna", "/firmware"] + +ENTRYPOINT ["./build.sh", "-d", "/firmware"] +CMD [] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000000..25bf25d2af --- /dev/null +++ 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 espurna-build --build-arg UID=$(id -u) --build-arg GID=$(id -g) -f Dockerfile .. +``` + +## Examples + +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 +``` + + +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 espurna-build intermittech-quinled +```