Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions grocy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ RUN \
# Copy root filesystem
COPY rootfs /

# Set Timezone for PHP runtime
RUN printf '[PHP]\ndate.timezone = "${TZ}"\n' > /etc/php85/conf.d/50-tzone.ini

Comment on lines +74 to +76

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for existing init/entrypoint scripts where runtime config should be added
fd -t f -e sh -e bash . rootfs/etc

Repository: hassio-addons/app-grocy

Length of output: 165


🏁 Script executed:

#!/bin/bash
# Explore repository structure
echo "=== Repository structure ==="
git ls-files | head -30
echo ""
echo "=== Check for rootfs directory ==="
ls -la | grep -E '^d' | head -20
echo ""
echo "=== Search for init, docker-entrypoint, or startup scripts ==="
fd -t f \( -name "entrypoint*" -o -name "init*" -o -name "startup*" \) 
echo ""
echo "=== Directory tree of grocy folder ==="
fd -t d . grocy | head -20

Repository: hassio-addons/app-grocy

Length of output: 2338


🏁 Script executed:

#!/bin/bash
# Read the full Dockerfile to understand context
echo "=== Dockerfile around lines 74-76 ==="
cat -n grocy/Dockerfile | sed -n '65,85p'
echo ""
echo "=== Check init-grocy service directory ==="
fd -t f . grocy/rootfs/etc/s6-overlay/s6-rc.d/init-grocy
echo ""
echo "=== Check for any existing PHP config files in rootfs ==="
fd -t f . grocy/rootfs/etc/php85/
echo ""
echo "=== Search for any timezone references in the codebase ==="
rg -i "timezone|TZ" grocy/

Repository: hassio-addons/app-grocy

Length of output: 1321


🏁 Script executed:

#!/bin/bash
# Check the init-grocy run script
echo "=== init-grocy/run script ==="
cat -n grocy/rootfs/etc/s6-overlay/s6-rc.d/init-grocy/run
echo ""
echo "=== Existing PHP config (99-grocy.ini) ==="
cat -n grocy/rootfs/etc/php85/conf.d/99-grocy.ini
echo ""
echo "=== Check what type of service init-grocy is ==="
cat grocy/rootfs/etc/s6-overlay/s6-rc.d/init-grocy/type

Repository: hassio-addons/app-grocy

Length of output: 1962


🏁 Script executed:

#!/bin/bash
# Check Home Assistant addon documentation patterns
echo "=== Check config.yaml for TZ environment variable ==="
cat -n grocy/config.yaml
echo ""
echo "=== Check build.yaml ==="
cat -n grocy/build.yaml

Repository: hassio-addons/app-grocy

Length of output: 3372


Critical: Variable substitution won't work—feature is broken.

The single quotes in the printf command prevent shell expansion, so the literal string "${TZ}" will be written to the PHP ini file. Additionally, TZ is not defined as a build ARG, so this configuration cannot access runtime environment variables.

This addon uses s6-overlay service management. The correct approach is to configure the timezone at container startup in the init-grocy/run script (a oneshot s6-overlay service), which has access to the runtime TZ environment variable from Home Assistant:

🔧 Recommended fix
  1. Remove lines 74-76 from the Dockerfile (the broken RUN command)

  2. Add timezone configuration to grocy/rootfs/etc/s6-overlay/s6-rc.d/init-grocy/run before the existing logic:

# After the shebang and comments, before the directory existence check:

# Configure PHP timezone from Home Assistant runtime
bashio::log.debug "Configuring PHP timezone..."
printf '[PHP]\ndate.timezone = %s\n' "${TZ:-UTC}" > /etc/php85/conf.d/50-tzone.ini

This way, the timezone is configured at container startup using the TZ environment variable provided by Home Assistant, and users can change it without rebuilding the image.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@grocy/Dockerfile` around lines 74 - 76, Remove the broken Dockerfile RUN that
uses single quotes to write "${TZ}" (it prevents shell expansion) and instead
configure PHP timezone at container startup in the init-grocy/run oneshot s6
service; specifically, delete the printf RUN from the Dockerfile and add startup
logic in init-grocy/run (before the directory-existence check) that logs a debug
message and writes a PHP ini file setting date.timezone using the runtime TZ
environment variable with a sensible default (e.g., UTC).

# Build arguments
ARG BUILD_ARCH
ARG BUILD_DATE
Expand Down