Add entrypoint script to create .env from Docker environment variables
This commit is contained in:
@@ -23,6 +23,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
&& curl -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
|
&& curl -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar \
|
||||||
&& chmod +x /usr/local/bin/wp
|
&& chmod +x /usr/local/bin/wp
|
||||||
|
|
||||||
|
# Copy entrypoint script
|
||||||
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
|
|
||||||
# Copy application
|
# Copy application
|
||||||
USER www-data
|
USER www-data
|
||||||
WORKDIR /var/www/html
|
WORKDIR /var/www/html
|
||||||
@@ -36,3 +40,6 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|||||||
CMD curl -fsS http://localhost/ -o /dev/null || exit 1
|
CMD curl -fsS http://localhost/ -o /dev/null || exit 1
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
|
CMD ["/init"]
|
||||||
|
|||||||
31
docker-entrypoint.sh
Normal file
31
docker-entrypoint.sh
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Erstellt .env aus Docker Environment Variables
|
||||||
|
|
||||||
|
ENV_FILE="/var/www/html/.env"
|
||||||
|
|
||||||
|
# Nur erstellen wenn nicht existiert
|
||||||
|
if [ ! -f "$ENV_FILE" ]; then
|
||||||
|
cat > "$ENV_FILE" << EOF
|
||||||
|
WP_ENV=${WP_ENV:-production}
|
||||||
|
WP_HOME=${WP_HOME}
|
||||||
|
WP_SITEURL=${WP_SITEURL}
|
||||||
|
DB_NAME=${DB_NAME}
|
||||||
|
DB_USER=${DB_USER}
|
||||||
|
DB_PASSWORD=${DB_PASSWORD}
|
||||||
|
DB_HOST=${DB_HOST}
|
||||||
|
WP_REDIS_HOST=${WP_REDIS_HOST:-redis}
|
||||||
|
AUTH_KEY=${AUTH_KEY}
|
||||||
|
SECURE_AUTH_KEY=${SECURE_AUTH_KEY}
|
||||||
|
LOGGED_IN_KEY=${LOGGED_IN_KEY}
|
||||||
|
NONCE_KEY=${NONCE_KEY}
|
||||||
|
AUTH_SALT=${AUTH_SALT}
|
||||||
|
SECURE_AUTH_SALT=${SECURE_AUTH_SALT}
|
||||||
|
LOGGED_IN_SALT=${LOGGED_IN_SALT}
|
||||||
|
NONCE_SALT=${NONCE_SALT}
|
||||||
|
EOF
|
||||||
|
chown www-data:www-data "$ENV_FILE"
|
||||||
|
echo ".env created from environment variables"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Original entrypoint ausführen
|
||||||
|
exec "$@"
|
||||||
Reference in New Issue
Block a user