Initial commit for Elasticsearch OCI
This commit is contained in:
22
Dockerfile
Normal file
22
Dockerfile
Normal file
@@ -0,0 +1,22 @@
|
||||
FROM elasticsearch:8.11.3
|
||||
|
||||
# 1. Switch to Root for installation
|
||||
USER root
|
||||
|
||||
# 2. Install Network Tools (Debian based)
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ifupdown \
|
||||
iproute2 \
|
||||
iputils-ping \
|
||||
nano \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 3. Add Script
|
||||
COPY start_network.sh /start_network.sh
|
||||
RUN chmod +x /start_network.sh
|
||||
|
||||
# 4. Set Environment for Single Node (Easier for Homelab)
|
||||
ENV discovery.type=single-node
|
||||
ENV xpack.security.enabled=false
|
||||
|
||||
ENTRYPOINT ["/start_network.sh"]
|
||||
36
start_network.sh
Normal file
36
start_network.sh
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# --- CONFIGURATION ---
|
||||
IP=${STATIC_IP:-"192.168.0.118/24"}
|
||||
GW=${STATIC_GW:-"192.168.0.1"}
|
||||
DNS=${STATIC_DNS:-"192.168.0.113"}
|
||||
|
||||
echo "--- Elasticsearch Network Init ---"
|
||||
echo "Using IP: $IP"
|
||||
|
||||
# 1. Generate Network Config (Debian/Ubuntu Syntax)
|
||||
cat <<EOF > /etc/network/interfaces
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address $IP
|
||||
gateway $GW
|
||||
EOF
|
||||
|
||||
# 2. Set DNS
|
||||
echo "nameserver $DNS" > /etc/resolv.conf
|
||||
|
||||
# 3. Start Network
|
||||
sleep 5
|
||||
ifup eth0
|
||||
|
||||
# 4. Fix Permissions (in case volumes were mounted by root)
|
||||
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data
|
||||
chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/logs
|
||||
|
||||
# 5. Launch Elasticsearch as the correct user
|
||||
echo "--- Starting Elasticsearch ---"
|
||||
# We use 'runuser' to drop privileges from root -> elasticsearch
|
||||
exec runuser -u elasticsearch -- /usr/local/bin/docker-entrypoint.sh "$@"
|
||||
Reference in New Issue
Block a user