Skip to content

Commit a697a8f

Browse files
committed
fix: Resolved docker issues
1 parent 694c747 commit a697a8f

File tree

2 files changed

+63
-59
lines changed

2 files changed

+63
-59
lines changed

.devcontainer/Dockerfile

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
11
FROM mcr.microsoft.com/vscode/devcontainers/cpp:debian
22

33
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
4-
&& apt-get -y install --no-install-recommends \
5-
python3 \
6-
python3-pip \
7-
git \
8-
curl \
9-
fish \
10-
docker.io \
11-
build-essential \
12-
dos2unix \
13-
&& apt-get clean \
14-
&& rm -rf /var/lib/apt/lists/*
15-
16-
RUN usermod -aG docker vscode \
17-
&& mkdir -p /home/vscode/.local/share/CMakeTools \
18-
&& mkdir -p /home/vscode/.ssh \
19-
&& mkdir -p /home/vscode/.config/fish \
20-
&& chown -R vscode:vscode /home/vscode/.local /home/vscode/.ssh /home/vscode/.config \
21-
&& chmod 700 /home/vscode/.ssh
4+
&& apt-get -y install --no-install-recommends \
5+
python3 \
6+
python3-pip \
7+
git \
8+
curl \
9+
fish \
10+
docker.io \
11+
build-essential \
12+
dos2unix \
13+
&& apt-get clean \
14+
&& rm -rf /var/lib/apt/lists/* \
15+
&& usermod -aG docker vscode
16+
17+
RUN mkdir -p /home/vscode/.local/share/CMakeTools \
18+
&& mkdir -p /home/vscode/.ssh \
19+
&& mkdir -p /home/vscode/.config/fish \
20+
&& chown -R vscode:vscode /home/vscode/.local /home/vscode/.ssh /home/vscode/.config \
21+
&& chmod 700 /home/vscode/.ssh
2222

2323
RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh \
24-
&& arduino-cli config init
24+
&& arduino-cli config init
2525

2626
ENV PATH="/usr/local/bin:${PATH}"
2727
WORKDIR /workspace
2828

2929
COPY .devcontainer/arduino-cli.yaml /root/.arduino15/arduino-cli.yaml
3030
RUN arduino-cli core update-index --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json,https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json \
31-
&& arduino-cli core install --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json,https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json esp8266:esp8266 esp32:esp32 \
32-
&& arduino-cli lib install "OneWire" "ArduinoUnit"
31+
&& arduino-cli core install --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json,https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json esp8266:esp8266 esp32:esp32 \
32+
&& arduino-cli lib install "OneWire" "ArduinoUnit"
3333

3434
COPY .devcontainer/update-libraries.sh /usr/local/bin/
3535
RUN dos2unix /usr/local/bin/update-libraries.sh && \
36-
chmod +x /usr/local/bin/update-libraries.sh
36+
chmod +x /usr/local/bin/update-libraries.sh
3737

3838
RUN echo 'alias arduino-build="./build.sh build"\nalias arduino-test="./build.sh test"\nalias arduino-build-test="./build.sh all"' >> /home/vscode/.bashrc \
39-
&& echo 'set -gx PATH /usr/local/bin $PATH' >> /home/vscode/.config/fish/config.fish
39+
&& echo 'set -gx PATH /usr/local/bin $PATH' >> /home/vscode/.config/fish/config.fish
4040

4141
RUN if [ ! -f /home/vscode/.ssh/id_rsa ]; then \
42-
ssh-keygen -t rsa -b 4096 -N "" -C "devcontainer@local" -f /home/vscode/.ssh/id_rsa && \
43-
chmod 600 /home/vscode/.ssh/id_rsa && \
44-
chmod 644 /home/vscode/.ssh/id_rsa.pub && \
45-
chown vscode:vscode /home/vscode/.ssh/id_rsa /home/vscode/.ssh/id_rsa.pub; \
46-
fi
42+
ssh-keygen -t rsa -b 4096 -N "" -C "devcontainer@local" -f /home/vscode/.ssh/id_rsa && \
43+
chmod 600 /home/vscode/.ssh/id_rsa && \
44+
chmod 644 /home/vscode/.ssh/id_rsa.pub && \
45+
chown vscode:vscode /home/vscode/.ssh/id_rsa /home/vscode/.ssh/id_rsa.pub; \
46+
fi
4747

48-
RUN echo '#!/bin/sh\nchmod 666 /var/run/docker.sock\nexec "$@"' > /usr/local/bin/docker-entrypoint.sh \
49-
&& chmod +x /usr/local/bin/docker-entrypoint.sh
48+
RUN echo '#!/bin/sh\nchmod 666 /var/run/docker.sock\nnewgrp docker\nexec "$@"' > /usr/local/bin/docker-entrypoint.sh \
49+
&& chmod +x /usr/local/bin/docker-entrypoint.sh
5050

5151
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
52-
CMD ["sleep", "infinity"]
52+
CMD ["sleep", "infinity"]

.devcontainer/devcontainer.json

+32-28
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
{
2-
"name": "Arduino Library Development",
3-
"build": {
4-
"dockerfile": "Dockerfile",
5-
"context": ".."
6-
},
7-
"mounts": [
8-
"source=devcontainer_ssh,target=/home/vscode/.ssh,type=volume",
9-
"source=devcontainer_bash_history,target=/home/vscode/.bash_history,type=volume",
10-
"source=devcontainer_fish_history,target=/home/vscode/.local/share/fish/fish_history,type=volume",
11-
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
12-
],
13-
"customizations": {
14-
"vscode": {
15-
"extensions": [
16-
"vsciot-vscode.vscode-arduino",
17-
"ms-vscode.cpptools",
18-
"ms-azuretools.vscode-docker",
19-
"yzhang.markdown-all-in-one"
20-
],
21-
"settings": {
22-
"terminal.integrated.defaultProfile.linux": "fish",
23-
"arduino.path": "/usr/local/bin/arduino-cli"
24-
}
25-
}
26-
},
27-
"postCreateCommand": "arduino-cli core install arduino:avr && arduino-cli lib install ArduinoUnit && /usr/local/bin/update-libraries.sh",
28-
"remoteUser": "vscode"
29-
}
2+
"name": "Arduino Library Development",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": ".."
6+
},
7+
"mounts": [
8+
"source=devcontainer_ssh,target=/home/vscode/.ssh,type=volume",
9+
"source=devcontainer_bash_history,target=/home/vscode/.bash_history,type=volume",
10+
"source=devcontainer_fish_history,target=/home/vscode/.local/share/fish/fish_history,type=volume",
11+
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
12+
],
13+
"runArgs": [
14+
"--init",
15+
"--privileged"
16+
],
17+
"customizations": {
18+
"vscode": {
19+
"extensions": [
20+
"vsciot-vscode.vscode-arduino",
21+
"ms-vscode.cpptools",
22+
"ms-azuretools.vscode-docker",
23+
"yzhang.markdown-all-in-one"
24+
],
25+
"settings": {
26+
"terminal.integrated.defaultProfile.linux": "fish",
27+
"arduino.path": "/usr/local/bin/arduino-cli"
28+
}
29+
}
30+
},
31+
"postCreateCommand": "arduino-cli core install arduino:avr && arduino-cli lib install ArduinoUnit && /usr/local/bin/update-libraries.sh",
32+
"remoteUser": "vscode"
33+
}

0 commit comments

Comments
 (0)