1
1
FROM mcr.microsoft.com/vscode/devcontainers/cpp:debian
2
2
3
- # Install required packages
4
3
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5
- && apt-get -y install --no-install-recommends \
6
- python3 \
7
- python3-pip \
8
- git \
9
- curl \
10
- fish \
11
- && apt-get clean \
12
- && rm -rf /var/lib/apt/lists/*
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
22
+
23
+ RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh \
24
+ && arduino-cli config init
13
25
14
- RUN mkdir -p /home/vscode/.local/share/CMakeTools \
15
- && chown -R vscode:vscode /home/vscode/.local/share/CMakeTools
16
-
17
- RUN mkdir -p /home/vscode/.ssh \
18
- && chown vscode:vscode /home/vscode/.ssh \
19
- && chmod 700 /home/vscode/.ssh
20
-
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
26
-
27
- # Add arduino-cli to PATH
28
26
ENV PATH="/usr/local/bin:${PATH}"
29
-
30
- # Create workspace directory
31
27
WORKDIR /workspace
32
28
33
- # Copy arduino-cli configuration (customise to your actual path)
34
- COPY arduino-cli.yaml /root/.arduino15/arduino-cli.yaml
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
29
+ COPY .devcontainer/arduino-cli.yaml /root/.arduino15/arduino-cli.yaml
30
+ 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"
43
33
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
34
COPY .devcontainer/update-libraries.sh /usr/local/bin/
54
- RUN chmod +x /usr/local/bin/update-libraries.sh
55
-
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
35
+ RUN dos2unix /usr/local/bin/update-libraries.sh && \
36
+ chmod +x /usr/local/bin/update-libraries.sh
66
37
67
- # Fix fish permissions
68
- RUN mkdir -p /home/vscode/.config && \
69
- chown -R vscode:vscode /home/vscode/.config
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
40
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
78
41
RUN if [ ! -f /home/vscode/.ssh/id_rsa ]; then \
79
- ssh-keygen -t rsa -b 4096 -N "" -C "devcontainer@local" -f /home/vscode/.ssh/id_rsa && \
80
- chmod 600 /home/vscode/.ssh/id_rsa && \
81
- chmod 644 /home/vscode/.ssh/id_rsa.pub && \
82
- chown vscode:vscode /home/vscode/.ssh/id_rsa /home/vscode/.ssh/id_rsa.pub ; \
83
- fi
84
-
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
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
90
47
91
- # Create and configure entrypoint script
92
48
RUN echo '#!/bin/sh\n chmod 666 /var/run/docker.sock\n exec "$@"' > /usr/local/bin/docker-entrypoint.sh \
93
- && chmod +x /usr/local/bin/docker-entrypoint.sh
49
+ && chmod +x /usr/local/bin/docker-entrypoint.sh
94
50
95
51
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh" ]
96
- CMD ["sleep" , "infinity" ]
52
+ CMD ["sleep" , "infinity" ]
0 commit comments