Update package build process, add .env template, and update to Cloudron base 5.0.0

This commit is contained in:
Andreas Düren 2025-03-17 09:04:47 +01:00
parent 167128b6a7
commit bd4dea4757
4 changed files with 39 additions and 9 deletions

12
.env.template Normal file
View File

@ -0,0 +1,12 @@
# Elasticsearch environment variables
# This file will be copied to /app/data/.env during installation
# Java memory settings - leave empty to auto-configure based on container limits
ES_JAVA_HEAP=
# Security settings - DO NOT CHANGE
ES_JAVA_HOME=/app/data/jdk
ES_PATH_CONF=/app/data/config
# Certificate password - DO NOT CHANGE
CERT_PASSWORD=cloudron

View File

@ -1,6 +1,6 @@
FROM cloudron/base:4.0.0
FROM cloudron/base:5.0.0
# Install dependencies and OpenJDK 17
# Install dependencies
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:openjdk-r/ppa && \
@ -18,7 +18,7 @@ RUN apt-get update && \
dnsutils \
openjdk-17-jdk
# Set environment variables
# Set Elasticsearch version
ENV ELASTIC_VERSION=8.17.3
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
@ -33,7 +33,7 @@ RUN mkdir -p /usr/share/elasticsearch && \
mv /usr/share/elasticsearch-${ELASTIC_VERSION}/* /usr/share/elasticsearch/ && \
rm -rf /usr/share/elasticsearch-${ELASTIC_VERSION} elasticsearch-${ELASTIC_VERSION}-linux-x86_64.tar.gz
# Create necessary directories for data and configuration
# Create necessary directories
RUN mkdir -p /app/data/{elasticsearch,logs,config,secrets,jdk/bin,run} && \
chown -R elasticsearch:elasticsearch /app/data
@ -41,10 +41,13 @@ RUN mkdir -p /app/data/{elasticsearch,logs,config,secrets,jdk/bin,run} && \
COPY elasticsearch.yml /app/elasticsearch.yml
COPY start.sh /app/start.sh
COPY stop.sh /app/stop.sh
# Set permissions
RUN chmod +x /app/start.sh /app/stop.sh
# Add healthcheck
# Health check
HEALTHCHECK --interval=15s --timeout=10s --start-period=120s --retries=5 \
CMD curl -fs -u elastic:$(cat /app/data/secrets/elastic_password) http://localhost:9200/_cluster/health?pretty || exit 1
# Command to run
CMD ["/app/start.sh"]

View File

@ -6,10 +6,10 @@ mkdir -p build
rm -rf build/*
# Copy all files to the build directory
cp -r CloudronManifest.json Dockerfile .env start.sh stop.sh README.md logo.png build/
cp -r CloudronManifest.json Dockerfile .env.template elasticsearch.yml start.sh stop.sh README.md logo.png build/
# Create the package
cd build
cloudron package
cloudron build --set-repository andreasdueren/elasticsearch-cloudron --tag latest
echo "Package created successfully!"

View File

@ -1,8 +1,23 @@
#!/bin/bash
set -e
# Source environment variables (if the file exists)
[ -f /app/.env ] && source /app/.env || echo "No .env file found, using default environment variables"
# Check and create .env file if it doesn't exist
if [ ! -f /app/data/.env ]; then
echo "Creating default .env file..."
cp /app/.env.template /app/data/.env
chown elasticsearch:elasticsearch /app/data/.env
chmod 600 /app/data/.env
fi
# Load environment variables from .env file if it exists
if [ -f /app/data/.env ]; then
echo "Loading environment variables from .env file..."
set -o allexport
source /app/data/.env
set +o allexport
else
echo "No .env file found, using default environment variables"
fi
# Set constants
ES_HOME=/usr/share/elasticsearch