105 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
ARG BUILD_FROM=ghcr.io/hassio-addons/base:18.1.1
 | 
						|
FROM ${BUILD_FROM}
 | 
						|
 | 
						|
# 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"
 | 
						|
 | 
						|
# Build arguments
 | 
						|
ARG BUILD_ARCH
 | 
						|
ARG BUILD_DATE
 | 
						|
ARG BUILD_DESCRIPTION
 | 
						|
ARG BUILD_NAME
 | 
						|
ARG BUILD_REF
 | 
						|
ARG BUILD_REPOSITORY
 | 
						|
ARG BUILD_VERSION
 | 
						|
 | 
						|
# 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-jre-headless \
 | 
						|
        openjdk17 \
 | 
						|
        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/x86_64/amd64}.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 \
 | 
						|
        "${OPENSEARCH_DATA_DIR}" \
 | 
						|
        "${OPENSEARCH_LOGS_DIR}" \
 | 
						|
        "${OPENSEARCH_PATH_CONF}" \
 | 
						|
        "${OPENSEARCH_PLUGINS_DIR}" \
 | 
						|
    && chown -R opensearch:opensearch /usr/share/opensearch
 | 
						|
 | 
						|
# Copy root filesystem
 | 
						|
COPY rootfs /
 | 
						|
 | 
						|
# 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"] |