test
This commit is contained in:
@@ -1,44 +1,104 @@
|
||||
ARG BASE_IMAGE=opensearchproject/opensearch:latest
|
||||
FROM ${BASE_IMAGE}
|
||||
ARG BUILD_FROM=ghcr.io/hassio-addons/base:18.1.1
|
||||
FROM ${BUILD_FROM}
|
||||
|
||||
# Switch to root user to install packages
|
||||
USER root
|
||||
# Set environment variables
|
||||
ENV \
|
||||
LANG=C.UTF-8 \
|
||||
OPENSEARCH_HOME="/usr/share/opensearch" \
|
||||
OPENSEARCH_PATH_CONF="/usr/share/opensearch/config" \
|
||||
OPENSEARCH_DATA_DIR="/usr/share/opensearch/data" \
|
||||
OPENSEARCH_LOGS_DIR="/usr/share/opensearch/logs" \
|
||||
OPENSEARCH_PLUGINS_DIR="/usr/share/opensearch/plugins" \
|
||||
PATH="/usr/share/opensearch/bin:$PATH"
|
||||
|
||||
# Install dependencies for configuration
|
||||
RUN if command -v dnf >/dev/null 2>&1; then \
|
||||
echo "Installing with dnf" && \
|
||||
dnf install -y gettext jq && \
|
||||
dnf clean all; \
|
||||
elif command -v yum >/dev/null 2>&1; then \
|
||||
echo "Installing with yum" && \
|
||||
yum install -y gettext jq && \
|
||||
yum clean all; \
|
||||
elif command -v microdnf >/dev/null 2>&1; then \
|
||||
echo "Installing with microdnf" && \
|
||||
microdnf install -y gettext jq && \
|
||||
microdnf clean all; \
|
||||
elif command -v apt-get >/dev/null 2>&1; then \
|
||||
echo "Installing with apt-get" && \
|
||||
apt-get update -y && \
|
||||
apt-get install -y gettext-base jq && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
else \
|
||||
echo "No package manager found! Checking if envsubst and jq are already available..." && \
|
||||
command -v envsubst || echo "envsubst not found" && \
|
||||
command -v jq || echo "jq not found"; \
|
||||
fi
|
||||
# Build arguments
|
||||
ARG BUILD_ARCH
|
||||
ARG BUILD_DATE
|
||||
ARG BUILD_DESCRIPTION
|
||||
ARG BUILD_NAME
|
||||
ARG BUILD_REF
|
||||
ARG BUILD_REPOSITORY
|
||||
ARG BUILD_VERSION
|
||||
|
||||
# Copy configuration files and scripts
|
||||
COPY rootfs/ /
|
||||
# Set OpenSearch version
|
||||
ARG OPENSEARCH_VERSION=2.11.0
|
||||
|
||||
# Install required dependencies
|
||||
RUN \
|
||||
apk add --no-cache --virtual .build-deps \
|
||||
curl \
|
||||
tar \
|
||||
gzip \
|
||||
gnupg \
|
||||
&& apk add --no-cache \
|
||||
openjdk17-jdk-headless \
|
||||
jq \
|
||||
gettext \
|
||||
bash \
|
||||
su-exec \
|
||||
tini \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
# Create opensearch user and group
|
||||
RUN \
|
||||
addgroup -S -g 1000 opensearch \
|
||||
&& adduser -S -u 1000 -G opensearch -H -h /usr/share/opensearch opensearch
|
||||
|
||||
# Download and install OpenSearch
|
||||
RUN \
|
||||
mkdir -p /tmp/opensearch \
|
||||
&& cd /tmp/opensearch \
|
||||
&& curl -fsSL "https://artifacts.opensearch.org/releases/bundle/opensearch/${OPENSEARCH_VERSION}/opensearch-${OPENSEARCH_VERSION}-linux-${BUILD_ARCH}.tar.gz" -o opensearch.tar.gz \
|
||||
&& tar -xzf opensearch.tar.gz --strip-components=1 \
|
||||
&& mv * /usr/share/opensearch \
|
||||
&& rm -rf /tmp/opensearch \
|
||||
&& chown -R opensearch:opensearch /usr/share/opensearch
|
||||
|
||||
# Create directories and set permissions
|
||||
RUN mkdir -p /usr/share/opensearch/config/jvm.options.d && \
|
||||
chown -R opensearch:opensearch /usr/share/opensearch && \
|
||||
chmod +x /usr/bin/configure-opensearch
|
||||
RUN \
|
||||
mkdir -p \
|
||||
"${OPENSEARCH_DATA_DIR}" \
|
||||
"${OPENSEARCH_LOGS_DIR}" \
|
||||
"${OPENSEARCH_PATH_CONF}" \
|
||||
"${OPENSEARCH_PLUGINS_DIR}" \
|
||||
&& chown -R opensearch:opensearch /usr/share/opensearch
|
||||
|
||||
# Switch back to opensearch user
|
||||
USER opensearch
|
||||
# Copy root filesystem
|
||||
COPY rootfs /
|
||||
|
||||
# Use our custom entrypoint script
|
||||
# Set permissions
|
||||
RUN \
|
||||
chmod a+x \
|
||||
/usr/bin/configure-opensearch \
|
||||
/usr/share/opensearch/bin/* \
|
||||
&& chown -R opensearch:opensearch /usr/share/opensearch
|
||||
|
||||
# Clean up build dependencies
|
||||
RUN apk del .build-deps
|
||||
|
||||
# Expose ports
|
||||
EXPOSE 9200 9300
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=30s --start-period=300s --retries=3 \
|
||||
CMD curl -f http://localhost:9200/_cluster/health || exit 1
|
||||
|
||||
# Labels
|
||||
LABEL \
|
||||
io.hass.name="OpenSearch Master" \
|
||||
io.hass.description="OpenSearch master node for Home Assistant" \
|
||||
io.hass.arch="${BUILD_ARCH}" \
|
||||
io.hass.type="addon" \
|
||||
io.hass.version="${BUILD_VERSION}" \
|
||||
maintainer="Your Name" \
|
||||
org.opencontainers.image.title="OpenSearch Master" \
|
||||
org.opencontainers.image.description="OpenSearch master node for Home Assistant" \
|
||||
org.opencontainers.image.vendor="Home Assistant Local Add-ons" \
|
||||
org.opencontainers.image.authors="Your Name" \
|
||||
org.opencontainers.image.licenses="Apache-2.0" \
|
||||
org.opencontainers.image.url="https://github.com/your-username/your-repo" \
|
||||
org.opencontainers.image.source="https://github.com/your-username/your-repo/opensearch-master" \
|
||||
org.opencontainers.image.documentation="https://github.com/your-username/your-repo/blob/main/opensearch-master/README.md"
|
||||
|
||||
# Set entrypoint
|
||||
ENTRYPOINT ["/usr/bin/configure-opensearch"]
|
||||
Reference in New Issue
Block a user