services-xbee_net/Dockerfile

50 lines
1.7 KiB
Docker

# Use an official Rust image as the base
FROM rust:latest
# Install necessary packages
RUN apt-get update && apt-get install -y \
libudev-dev \
iproute2 \
iputils-ping \
net-tools \
bridge-utils \
iptables \
supervisor \
traceroute \
&& rm -rf /var/lib/apt/lists/*
# Clone the xbnet repository
# The xbnet repository contains the source code needed to set up and manage the XBee network
RUN git clone https://github.com/jgoerzen/xbnet.git /usr/src/xbnet
# Build xbnet
# We build the xbnet project from source using Cargo, Rust's package manager and build system
WORKDIR /usr/src/xbnet
RUN cargo build --release
# Copy the built binary to /usr/local/bin
# The xbnet binary will be placed in /usr/local/bin to be accessible system-wide
RUN cp target/release/xbnet /usr/local/bin/xbnet
# Copy the entrypoint script
# The entrypoint script handles the setup and monitoring of the XBee network
COPY ./scripts/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Copy the supervisor config file
# Supervisor configuration ensures that the XBee network service is managed and stays running
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Copy the health check script
# The health check script will be used by Docker to monitor the health of the container
COPY ./scripts/health_check.sh /health_check.sh
RUN chmod +x /health_check.sh
# Start supervisord as the main command
# Supervisord will manage and monitor the services, including the XBee network
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
# Add healthcheck
# The health check command periodically checks the health of the container using a custom script
HEALTHCHECK CMD /health_check.sh || exit 1