Fix Docker Compose and Dockerfile issues: remove image pull, fix entrypoint permissions

This commit is contained in:
Ducky SSH User
2025-12-20 06:36:20 +00:00
parent e0b8f8650b
commit a5a683d1de
3 changed files with 21 additions and 25 deletions

View File

@@ -25,21 +25,21 @@ WORKDIR /app
COPY --from=builder /app/nerd-monitor-agent .
# Create entrypoint script BEFORE switching users
RUN echo '#!/bin/sh' > /app/entrypoint.sh && \
echo 'SERVER=${SERVER:-localhost:8080}' >> /app/entrypoint.sh && \
echo 'INTERVAL=${INTERVAL:-15s}' >> /app/entrypoint.sh && \
echo 'AGENT_ID=${AGENT_ID:-}' >> /app/entrypoint.sh && \
echo 'if [ -z "$AGENT_ID" ]; then' >> /app/entrypoint.sh && \
echo ' exec ./nerd-monitor-agent --server "$SERVER" --interval "$INTERVAL"' >> /app/entrypoint.sh && \
echo 'else' >> /app/entrypoint.sh && \
echo ' exec ./nerd-monitor-agent --server "$SERVER" --interval "$INTERVAL" --id "$AGENT_ID"' >> /app/entrypoint.sh && \
echo 'fi' >> /app/entrypoint.sh && \
chmod +x /app/entrypoint.sh
# Create non-root user
RUN addgroup -D appgroup && adduser -D appuser -G appgroup
USER appuser
# Create entrypoint script to handle environment variables
RUN echo '#!/bin/sh\n\
SERVER=${SERVER:-localhost:8080}\n\
INTERVAL=${INTERVAL:-15s}\n\
AGENT_ID=${AGENT_ID:-}\n\
if [ -z "$AGENT_ID" ]; then\n\
exec ./nerd-monitor-agent --server "$SERVER" --interval "$INTERVAL"\n\
else\n\
exec ./nerd-monitor-agent --server "$SERVER" --interval "$INTERVAL" --id "$AGENT_ID"\n\
fi\n\
' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
# Run the agent
ENTRYPOINT ["/app/entrypoint.sh"]