Skip to content

Commit 8b5c42c

Browse files
committed
chore: interim commit
1 parent a697a8f commit 8b5c42c

File tree

4 files changed

+80
-38
lines changed

4 files changed

+80
-38
lines changed

.devcontainer/Dockerfile

+73-32
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,93 @@
1+
# Use the base image for C++ development
12
FROM mcr.microsoft.com/vscode/devcontainers/cpp:debian
23

4+
# Install required packages
35
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-
&& usermod -aG docker vscode
6+
&& apt-get -y install --no-install-recommends \
7+
python3 \
8+
python3-pip \
9+
git \
10+
curl \
11+
fish \
12+
docker.io \
13+
build-essential \
14+
dos2unix \
15+
&& apt-get clean \
16+
&& rm -rf /var/lib/apt/lists/*
1617

18+
# Add vscode user to the docker group
19+
RUN usermod -aG docker vscode
20+
21+
# Create necessary directories and set permissions
1722
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
23+
&& mkdir -p /home/vscode/.ssh \
24+
&& mkdir -p /home/vscode/.config/fish \
25+
&& chown -R vscode:vscode /home/vscode/.local /home/vscode/.ssh /home/vscode/.config \
26+
&& chmod 700 /home/vscode/.ssh
27+
28+
# Install arduino-cli
29+
RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
2230

23-
RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh \
24-
&& arduino-cli config init
31+
# Set up arduino-cli config
32+
RUN arduino-cli config init
2533

34+
# Add arduino-cli to PATH
2635
ENV PATH="/usr/local/bin:${PATH}"
36+
37+
# Create workspace directory
2738
WORKDIR /workspace
2839

40+
# Copy arduino-cli configuration (customize to your actual path)
2941
COPY .devcontainer/arduino-cli.yaml /root/.arduino15/arduino-cli.yaml
42+
43+
# Install Arduino cores for ESP8266 and ESP32
3044
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"
45+
&& arduino-cli core install esp8266:esp8266 --additional-urls https://arduino.esp8266.com/stable/package_esp8266com_index.json \
46+
&& arduino-cli core install esp32:esp32 --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
3347

48+
# Install required Arduino libraries
49+
RUN arduino-cli lib install "OneWire" "ArduinoUnit"
50+
51+
# Verify library installation
52+
RUN arduino-cli lib list
53+
54+
# Copy update script and set permissions
3455
COPY .devcontainer/update-libraries.sh /usr/local/bin/
35-
RUN dos2unix /usr/local/bin/update-libraries.sh && \
36-
chmod +x /usr/local/bin/update-libraries.sh
56+
RUN dos2unix /usr/local/bin/update-libraries.sh \
57+
&& chmod +x /usr/local/bin/update-libraries.sh
58+
59+
# Add aliases for build operations (for Bash)
60+
RUN echo 'alias arduino-build="./build.sh build"' >> /home/vscode/.bashrc \
61+
&& echo 'alias arduino-test="./build.sh test"' >> /home/vscode/.bashrc \
62+
&& echo 'alias arduino-build-test="./build.sh all"' >> /home/vscode/.bashrc
63+
64+
# Add a welcome message to .bashrc
65+
RUN echo '\n# Welcome to the dev container! Here are some useful aliases:' >> /home/vscode/.bashrc \
66+
&& echo 'echo " - arduino-build: Build the project"' >> /home/vscode/.bashrc \
67+
&& echo 'echo " - arduino-test: Run tests for the project"' >> /home/vscode/.bashrc \
68+
&& echo 'echo " - arduino-build-test: Build and test the project"' >> /home/vscode/.bashrc
3769

38-
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
70+
# Add aliases and welcome message for Fish shell
71+
RUN echo 'alias arduino-build="./build.sh build"' >> /home/vscode/.config/fish/config.fish \
72+
&& echo 'alias arduino-test="./build.sh test"' >> /home/vscode/.config/fish/config.fish \
73+
&& echo 'alias arduino-build-test="./build.sh all"' >> /home/vscode/.config/fish/config.fish \
74+
&& echo '\n# Welcome to the dev container! Here are some useful aliases:' >> /home/vscode/.config/fish/config.fish \
75+
&& echo 'echo " - arduino-build: Build the project"' >> /home/vscode/.config/fish/config.fish \
76+
&& echo 'echo " - arduino-test: Run tests for the project"' >> /home/vscode/.config/fish/config.fish \
77+
&& echo 'echo " - arduino-build-test: Build and test the project"' >> /home/vscode/.config/fish/config.fish
4078

79+
# Generate SSH keys and set proper ownership and permissions
4180
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
81+
ssh-keygen -t rsa -b 4096 -N "" -C "devcontainer@local" -f /home/vscode/.ssh/id_rsa \
82+
&& chmod 600 /home/vscode/.ssh/id_rsa \
83+
&& chmod 644 /home/vscode/.ssh/id_rsa.pub \
84+
&& chown vscode:vscode /home/vscode/.ssh/id_rsa /home/vscode/.ssh/id_rsa.pub ; \
85+
fi
4786

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
87+
# Ensure the Docker socket has the correct permissions
88+
RUN echo '#!/bin/sh\nsudo chmod 666 /var/run/docker.sock\nexec "$@"' > /usr/local/bin/docker-entrypoint.sh \
89+
&& chmod +x /usr/local/bin/docker-entrypoint.sh
5090

91+
# Set the entrypoint to fix permissions and start the container
5192
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
52-
CMD ["sleep", "infinity"]
93+
CMD ["sleep", "infinity"]

.devcontainer/arduino-cli.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ compile:
66
# - zero # SAMD covered by M4
77
# - leonardo # AVR covered by UNO
88
- m4
9-
# - esp32 # errors on OneWire => util/crc16.h vs rom/crc.h
10-
# - esp8266
9+
- esp32
10+
- esp8266
1111
# - mega2560 # AVR covered by UNO
1212
unittest:
1313
# These dependent libraries will be installed

.devcontainer/devcontainer.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
1212
],
1313
"runArgs": [
14-
"--init",
15-
"--privileged"
14+
"--init"
1615
],
1716
"customizations": {
1817
"vscode": {
@@ -28,6 +27,6 @@
2827
}
2928
}
3029
},
31-
"postCreateCommand": "arduino-cli core install arduino:avr && arduino-cli lib install ArduinoUnit && /usr/local/bin/update-libraries.sh",
30+
"postCreateCommand": "echo 'Welcome to the Arduino Library Development Environment!' && arduino-cli core install arduino:avr && arduino-cli lib install ArduinoUnit && /usr/local/bin/update-libraries.sh",
3231
"remoteUser": "vscode"
33-
}
32+
}

test-docker/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM alpine
2+
CMD ["echo", "Hello from Docker-in-Docker!"]

0 commit comments

Comments
 (0)