Skip to content

Commit 4447101

Browse files
committed
fix: Experimenting with docker in docker for local testing
1 parent e38abd3 commit 4447101

File tree

1 file changed

+59
-26
lines changed

1 file changed

+59
-26
lines changed

.devcontainer/Dockerfile

+59-26
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,89 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
88
git \
99
curl \
1010
fish \
11-
docker.io \
12-
sudo \
13-
build-essential \
1411
&& apt-get clean \
1512
&& rm -rf /var/lib/apt/lists/*
1613

17-
# Add user to docker group
18-
RUN usermod -aG docker vscode
19-
20-
# Create directories and set permissions
2114
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 \
2418
&& chown vscode:vscode /home/vscode/.ssh \
2519
&& chmod 700 /home/vscode/.ssh
2620

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
3026

27+
# Add arduino-cli to PATH
3128
ENV PATH="/usr/local/bin:${PATH}"
29+
30+
# Create workspace directory
3231
WORKDIR /workspace
3332

34-
# Copy Arduino config and update script
33+
# Copy arduino-cli configuration (customise to your actual path)
3534
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/
3754
RUN chmod +x /usr/local/bin/update-libraries.sh
3855

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
4366

44-
# Configure shells
45-
RUN echo 'alias arduino-build="./build.sh build"\nalias arduino-test="./build.sh test"\nalias arduino-build-test="./build.sh all"' >> /home/vscode/.bashrc \
46-
&& echo '\n# Welcome to the dev container! Here are some useful aliases:\necho " - arduino-build: Build the project"\necho " - arduino-test: Run tests for the project"\necho " - 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
4970

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
5178
RUN if [ ! -f /home/vscode/.ssh/id_rsa ]; then \
5279
ssh-keygen -t rsa -b 4096 -N "" -C "devcontainer@local" -f /home/vscode/.ssh/id_rsa && \
5380
chmod 600 /home/vscode/.ssh/id_rsa && \
5481
chmod 644 /home/vscode/.ssh/id_rsa.pub && \
5582
chown vscode:vscode /home/vscode/.ssh/id_rsa /home/vscode/.ssh/id_rsa.pub ; \
5683
fi
5784

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
5992
RUN echo '#!/bin/sh\nchmod 666 /var/run/docker.sock\nexec "$@"' > /usr/local/bin/docker-entrypoint.sh \
6093
&& chmod +x /usr/local/bin/docker-entrypoint.sh
6194

6295
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
63-
CMD ["sleep", "infinity"]
96+
CMD ["sleep", "infinity"]

0 commit comments

Comments
 (0)