From 5f0ef0bf04c012ba037c7eb1eec2463a1edbd7f3 Mon Sep 17 00:00:00 2001 From: lior Date: Wed, 4 Sep 2024 10:27:33 +0300 Subject: [PATCH 1/3] current progress --- .dockerignire | 3 +++ .github/workflows/build.yml | 2 +- Dockerfile | 53 +++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .dockerignire create mode 100644 Dockerfile diff --git a/.dockerignire b/.dockerignire new file mode 100644 index 00000000..ebd21a9b --- /dev/null +++ b/.dockerignire @@ -0,0 +1,3 @@ +.github +.vscode* + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a13c0f7..b0dea47b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,7 +83,7 @@ jobs: run: | export NODE_OPTIONS="--openssl-legacy-provider --no-experimental-fetch" node build/package.js - - name: Build and pack extension + - name: Build and pack extension (windows) if: ${{ matrix.os == 'windows-latest' }} run: | $env:NODE_OPTIONS="--openssl-legacy-provider --no-experimental-fetch" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..95a78b8b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# get python version 3.8 +FROM python:3.8.19-bookworm +# get nodejs version 20 in debian flavor +FROM node:20.17-bookworm + + +SHELL ["/bin/bash", "-c"] + +# install utility packages +RUN apt update +RUN apt install -y openssh-server openssh-sftp-server bash sudo zsh net-tools vim git +# install project tool dependancies +# RUN ls /usr/local/lib/node_modules/npm 1>&2 && exit 1 +RUN npm install -g gulp node-gyp @vscode/vsce +RUN apt install -y g++-multilib build-essential libudev-dev + +# SSHD configuration +EXPOSE 22/tcp +RUN mkdir /run/sshd +RUN mkdir -p /var/run/sshd + + +# Volume configuration +VOLUME ["/host_dir"] + +# User configuration +RUN adduser --shell /bin/bash --home /home/ubuntu ubuntu +RUN usermod -aG sudo ubuntu +WORKDIR /home/ubuntu +USER ubuntu:ubuntu + +# configure powerlevel10k +RUN git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k +RUN echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc + +# copy the repository into the container +COPY --chown=ubuntu:ubuntu . /vscode-arduino + +# clone arduino tools +RUN wget https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz -P /home/ubuntu +RUN node /vscode-arduino/build/checkHash.js /home/ubuntu/arduino-1.8.19-linux64.tar.xz eb68bddc1d1c0120be2fca1350a03ee34531cf37f51847b21210b6e70545bc9b +RUN tar -xvf /home/ubuntu/arduino-1.8.19-linux64.tar.xz -C /home/ubuntu +USER root:root +RUN ln -s /home/ubuntu/arduino-1.8.19/arduino /usr/bin/arduino +USER ubuntu:ubuntu + +# install npm dependencies +WORKDIR /vscode-arduino +RUN env CXX="g++" CC="gcc" + +USER root:root +WORKDIR /home/ubuntu +ENTRYPOINT ["/bin/zsh", "-c", "/usr/sbin/sshd && su ubuntu"] From acf7df6fd49444ae1be4599c7091d828357250d1 Mon Sep 17 00:00:00 2001 From: lior Date: Sun, 8 Sep 2024 23:26:40 +0300 Subject: [PATCH 2/3] a working docker file --- .vscodeignore | 2 ++ Dockerfile | 46 +++++++++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.vscodeignore b/.vscodeignore index 1afd33a2..f88bb994 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -19,6 +19,8 @@ vendor/** azure-pipelines.yml build/** assets/platform/** +.dockerignore +Dockerfile # A platform-specific directory in assets/platform/ will be added to the end of # this file by the packaging script. diff --git a/Dockerfile b/Dockerfile index 95a78b8b..7d1ae694 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,31 @@ -# get python version 3.8 -FROM python:3.8.19-bookworm -# get nodejs version 20 in debian flavor -FROM node:20.17-bookworm +FROM ubuntu:23.10 - -SHELL ["/bin/bash", "-c"] +# # set timezone ? +RUN ln -snf /usr/share/zoneinfo/Etc/Universal /etc/localtime # install utility packages RUN apt update -RUN apt install -y openssh-server openssh-sftp-server bash sudo zsh net-tools vim git +RUN apt install -y openssh-server openssh-sftp-server bash sudo zsh net-tools vim git python3.11 curl wget +SHELL ["/bin/bash", "-c"] + +# install node js +ENV NVM_DIR=/usr/local/nvm +ENV NODE_VERSION=18.20.4 +RUN mkdir -p $NVM_DIR && export NVM_DIR=$NVM_DIR && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash +RUN source $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm alias default $NODE_VERSION \ + && nvm use default +ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION/lib/node_modules +ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH + + # install project tool dependancies -# RUN ls /usr/local/lib/node_modules/npm 1>&2 && exit 1 RUN npm install -g gulp node-gyp @vscode/vsce -RUN apt install -y g++-multilib build-essential libudev-dev +RUN apt install -y g++-multilib build-essential libudev-dev unzip # SSHD configuration EXPOSE 22/tcp -RUN mkdir /run/sshd RUN mkdir -p /var/run/sshd @@ -24,8 +33,7 @@ RUN mkdir -p /var/run/sshd VOLUME ["/host_dir"] # User configuration -RUN adduser --shell /bin/bash --home /home/ubuntu ubuntu -RUN usermod -aG sudo ubuntu +RUN usermod --shell /bin/bash -aG sudo ubuntu WORKDIR /home/ubuntu USER ubuntu:ubuntu @@ -46,8 +54,16 @@ USER ubuntu:ubuntu # install npm dependencies WORKDIR /vscode-arduino -RUN env CXX="g++" CC="gcc" +ENV CXX="g++" +ENV CC="gcc" +RUN npm install -USER root:root WORKDIR /home/ubuntu -ENTRYPOINT ["/bin/zsh", "-c", "/usr/sbin/sshd && su ubuntu"] +USER root:root +RUN cat ~/.bashrc >> .bashrc +RUN echo "export NODE_PATH=$NVM_DIR/v$NODE_VERSION/lib/node_modules" >> .bashrc +RUN echo "export PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH" >> .bashrc +RUN echo "export NODE_OPTIONS=\"--openssl-legacy-provider --no-experimental-fetch\"" >> .bashrc +RUN echo "source $NVM_DIR/nvm.sh" >> .bashrc +RUN cat .bashrc >> .zshrc +ENTRYPOINT ["/bin/bash", "-c", "/usr/sbin/sshd && su ubuntu"] From 1ba3f6c4fa4d5f0ca6211a0c7ffe13e84a5a4ecc Mon Sep 17 00:00:00 2001 From: lior Date: Sun, 8 Sep 2024 23:42:35 +0300 Subject: [PATCH 3/3] added docker usage to read me --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2a9de148..11d046d1 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,9 @@ To *run and develop*, do the following: To *test*, press F5 in VS Code with the "Launch Tests" debug configuration. +You can also use `docker buid -t vscode-arduino:0.7.1 .` in order to create a container to compile the codebase +Then you can run `docker run --name vscode_arduino_builder -it -v :/host_dir vscode-arduino:0.7.1` + ## Code of Conduct This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct). For more information please see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/#howadopt) or contact opencode@microsoft.com with any additional questions or comments.