Skip to content

Commit 6ce83d6

Browse files
committed
Refactor: Conditional rootfs copy and S6 setup improvements
1 parent 6493590 commit 6ce83d6

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

Dockerfile

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,13 @@ RUN if echo "$BUILD_FROM" | grep -q "home-assistant"; then \
5252
mkdir -p /tmp/uv_test && uv venv /tmp/uv_test && rm -rf /tmp/uv_test && \
5353
# Install specific Node.js version for addon
5454
echo "Installing Node.js v${NODE_VERSION} for addon..." && \
55-
curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
56-
#apt-get update && \
57-
#sudo apt-get install -y nodejs npm \
58-
# Install S6-Overlay for addon service management
59-
echo "Installing S6-Overlay for addon..." && \
60-
S6_OVERLAY_VERSION=$(curl -sL "https://api.github.com/repos/just-containers/s6-overlay/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') && \
61-
echo "Latest S6-Overlay version: $S6_OVERLAY_VERSION" && \
62-
curl -o /usr/local/bin/s6-overlay-installer.sh -L "https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-installer.sh" && \
63-
chmod +x /usr/local/bin/s6-overlay-installer.sh && \
64-
/usr/local/bin/s6-overlay-installer.sh / && \
55+
#curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
56+
# Ensure Node.js and npm are installed if using this path.
57+
# The line below was `sudo apt-get install -y nodejs npm`.
58+
# `sudo` is generally not available or needed in Dockerfiles.
59+
# Also, `apt-get update` should precede `apt-get install`.
60+
apt-get update && apt-get install -y nodejs npm && \
61+
# S6-Overlay is assumed to be part of the Home Assistant base image.
6562
# Cleanup for addon OS setup
6663
echo "Cleaning up apt cache for addon OS setup..." && \
6764
apt-get clean && \
@@ -96,8 +93,24 @@ RUN if [ -n "$PRE_INSTALLED_INIT_COMMAND_ARG" ]; then \
9693
#COPY package.json package-lock.json* ./
9794
#COPY tsconfig.json ./
9895
#COPY public ./public
96+
# COPY . . should come before conditional rootfs copy if rootfs might overlay app files,
97+
# or after if app files might overlay rootfs defaults.
98+
# Assuming app files are primary, then addon specifics overlay.
9999
COPY . .
100100

101+
# --- Addon Specific: Copy rootfs for S6-Overlay and other addon specific files ---
102+
RUN if echo "$BUILD_FROM" | grep -q "home-assistant"; then \
103+
echo "Addon build: Copying rootfs contents..." && \
104+
# Ensure rootfs directory exists in the build context
105+
if [ -d "rootfs" ]; then \
106+
cp -r rootfs/. / ; \
107+
else \
108+
echo "Warning: rootfs directory not found, skipping copy."; \
109+
fi; \
110+
else \
111+
echo "Standalone build: Skipping rootfs copy."; \
112+
fi
113+
101114
RUN npm install
102115
RUN npm run build
103116

@@ -124,17 +137,6 @@ VOLUME /mcp-proxy-server/config
124137
# For external tools referenced in config, and default install location if TOOLS_FOLDER is /tools
125138
VOLUME /tools
126139

127-
RUN if echo "$BUILD_FROM" | grep -q "home-assistant"; then \
128-
echo "Addon build: Making S6 run script executable..." && \
129-
mkdir -p /etc/cont-init.d/ && \
130-
cp run.sh /etc/cont-init.d/99-run-mcp-proxy && \
131-
chmod +x /etc/cont-init.d/99-run-mcp-proxy; \
132-
else \
133-
echo "Standalone build: S6 run script not made executable (or should be removed if not needed)."; \
134-
# For a pure standalone build without S6, this file might be removed:
135-
# rm -f /etc/cont-init.d/99-run-mcp-proxy; \
136-
fi
137-
138140
# --- Expose Port ---
139141
EXPOSE 3663
140142

0 commit comments

Comments
 (0)