@@ -8,56 +8,89 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
8
8
git \
9
9
curl \
10
10
fish \
11
- docker.io \
12
- sudo \
13
- build-essential \
14
11
&& apt-get clean \
15
12
&& rm -rf /var/lib/apt/lists/*
16
13
17
- # Add user to docker group
18
- RUN usermod -aG docker vscode
19
-
20
- # Create directories and set permissions
21
14
RUN mkdir -p /home/vscode/.local/share/CMakeTools \
22
- && chown -R vscode:vscode /home/vscode/.local/share/CMakeTools \
23
- && mkdir -p /home/vscode/.ssh \
15
+ && chown -R vscode:vscode /home/vscode/.local/share/CMakeTools
16
+
17
+ RUN mkdir -p /home/vscode/.ssh \
24
18
&& chown vscode:vscode /home/vscode/.ssh \
25
19
&& chmod 700 /home/vscode/.ssh
26
20
27
- # Install Arduino CLI
28
- RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh \
29
- && arduino-cli config init
21
+ # Install arduino-cli
22
+ RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
23
+
24
+ # Set up arduino-cli config
25
+ RUN arduino-cli config init
30
26
27
+ # Add arduino-cli to PATH
31
28
ENV PATH="/usr/local/bin:${PATH}"
29
+
30
+ # Create workspace directory
32
31
WORKDIR /workspace
33
32
34
- # Copy Arduino config and update script
33
+ # Copy arduino-cli configuration (customise to your actual path)
35
34
COPY arduino-cli.yaml /root/.arduino15/arduino-cli.yaml
36
- COPY update-libraries.sh /usr/local/bin/
35
+
36
+ # Install build essentials
37
+ RUN apt-get update && apt-get install -y build-essential && rm -rf /var/lib/apt/lists/*
38
+
39
+ 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
40
+
41
+ # (Optional) Install Arduino cores for ESP8266 and ESP32 if needed
42
+ RUN 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
43
+
44
+ # Install only required dependencies for DallasTemperature library and others
45
+ RUN arduino-cli lib install \
46
+ "OneWire" \
47
+ "ArduinoUnit" # For testing
48
+
49
+ # Verify library installation
50
+ RUN arduino-cli lib list
51
+
52
+ # Copy update script
53
+ COPY .devcontainer/update-libraries.sh /usr/local/bin/
37
54
RUN chmod +x /usr/local/bin/update-libraries.sh
38
55
39
- # Install Arduino cores and libraries
40
- RUN arduino-cli core install esp8266:esp8266 esp32:esp32 \
41
- && arduino-cli lib install "OneWire" "ArduinoUnit" \
42
- && arduino-cli lib list
56
+ # Add aliases for build operations (for Bash)
57
+ RUN echo 'alias arduino-build="./build.sh build"' >> /home/vscode/.bashrc && \
58
+ echo 'alias arduino-test="./build.sh test"' >> /home/vscode/.bashrc && \
59
+ echo 'alias arduino-build-test="./build.sh all"' >> /home/vscode/.bashrc
60
+
61
+ # Add a welcome message to .bashrc
62
+ RUN echo '\n # Welcome to the dev container! Here are some useful aliases:' >> /home/vscode/.bashrc && \
63
+ echo 'echo " - arduino-build: Build the project"' >> /home/vscode/.bashrc && \
64
+ echo 'echo " - arduino-test: Run tests for the project"' >> /home/vscode/.bashrc && \
65
+ echo 'echo " - arduino-build-test: Build and test the project"' >> /home/vscode/.bashrc
43
66
44
- # Configure shells
45
- RUN echo 'alias arduino-build="./build.sh build"\n alias arduino-test="./build.sh test"\n alias arduino-build-test="./build.sh all"' >> /home/vscode/.bashrc \
46
- && echo '\n # Welcome to the dev container! Here are some useful aliases:\n echo " - arduino-build: Build the project"\n echo " - arduino-test: Run tests for the project"\n echo " - arduino-build-test: Build and test the project"' >> /home/vscode/.bashrc \
47
- && mkdir -p /home/vscode/.config/fish \
48
- && echo 'set -gx PATH /usr/local/bin $PATH\n # Welcome to the Fish shell inside the dev container!' >> /home/vscode/.config/fish/config.fish
67
+ # Fix fish permissions
68
+ RUN mkdir -p /home/vscode/.config && \
69
+ chown -R vscode:vscode /home/vscode/.config
49
70
50
- # Generate SSH keys
71
+ # (Optional) Add fish-specific configuration if desired
72
+ # For example, you might add an alias file or welcome message for fish:
73
+ RUN mkdir -p /home/vscode/.config/fish && \
74
+ echo 'set -gx PATH /usr/local/bin $PATH' >> /home/vscode/.config/fish/config.fish && \
75
+ echo '# Welcome to the Fish shell inside the dev container!' >> /home/vscode/.config/fish/config.fish
76
+
77
+ # Generate SSH keys and set proper ownership and permissions
51
78
RUN if [ ! -f /home/vscode/.ssh/id_rsa ]; then \
52
79
ssh-keygen -t rsa -b 4096 -N "" -C "devcontainer@local" -f /home/vscode/.ssh/id_rsa && \
53
80
chmod 600 /home/vscode/.ssh/id_rsa && \
54
81
chmod 644 /home/vscode/.ssh/id_rsa.pub && \
55
82
chown vscode:vscode /home/vscode/.ssh/id_rsa /home/vscode/.ssh/id_rsa.pub ; \
56
83
fi
57
84
58
- # Docker-in-Docker setup
85
+ # Install Docker
86
+ RUN apt-get update && apt-get install -y docker.io && rm -rf /var/lib/apt/lists/*
87
+
88
+ # Setup Docker permissions
89
+ RUN usermod -aG docker vscode
90
+
91
+ # Create and configure entrypoint script
59
92
RUN echo '#!/bin/sh\n chmod 666 /var/run/docker.sock\n exec "$@"' > /usr/local/bin/docker-entrypoint.sh \
60
93
&& chmod +x /usr/local/bin/docker-entrypoint.sh
61
94
62
95
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh" ]
63
- CMD ["sleep" , "infinity" ]
96
+ CMD ["sleep" , "infinity" ]
0 commit comments