1
+ # Use the base image for C++ development
1
2
FROM mcr.microsoft.com/vscode/devcontainers/cpp:debian
2
3
4
+ # Install required packages
3
5
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/*
16
17
18
+ # Add vscode user to the docker group
19
+ RUN usermod -aG docker vscode
20
+
21
+ # Create necessary directories and set permissions
17
22
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
22
30
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
25
33
34
+ # Add arduino-cli to PATH
26
35
ENV PATH="/usr/local/bin:${PATH}"
36
+
37
+ # Create workspace directory
27
38
WORKDIR /workspace
28
39
40
+ # Copy arduino-cli configuration (customize to your actual path)
29
41
COPY .devcontainer/arduino-cli.yaml /root/.arduino15/arduino-cli.yaml
42
+
43
+ # Install Arduino cores for ESP8266 and ESP32
30
44
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
33
47
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
34
55
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
37
69
38
- 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 \
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
40
78
79
+ # Generate SSH keys and set proper ownership and permissions
41
80
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
47
86
48
- RUN echo '#!/bin/sh\n chmod 666 /var/run/docker.sock\n newgrp docker\n exec "$@"' > /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\n sudo chmod 666 /var/run/docker.sock\n exec "$@"' > /usr/local/bin/docker-entrypoint.sh \
89
+ && chmod +x /usr/local/bin/docker-entrypoint.sh
50
90
91
+ # Set the entrypoint to fix permissions and start the container
51
92
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh" ]
52
- CMD ["sleep" , "infinity" ]
93
+ CMD ["sleep" , "infinity" ]
0 commit comments