Fix config generation loop and add gosu dependency
This commit is contained in:
@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y \
|
|||||||
git \
|
git \
|
||||||
build-essential \
|
build-essential \
|
||||||
libolm-dev \
|
libolm-dev \
|
||||||
|
gosu \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
@ -36,8 +37,8 @@ COPY start.sh /app/pkg/
|
|||||||
VOLUME /app/data
|
VOLUME /app/data
|
||||||
ENV UID=1337 GID=1337
|
ENV UID=1337 GID=1337
|
||||||
|
|
||||||
# Add health check endpoint
|
# Add health check endpoint - check if the appservice port is responding
|
||||||
HEALTHCHECK --interval=60s --timeout=10s --start-period=30s --retries=3 \
|
HEALTHCHECK --interval=60s --timeout=10s --start-period=30s --retries=3 \
|
||||||
CMD curl -f http://localhost:29318/health || exit 1
|
CMD nc -z localhost 29318 || exit 1
|
||||||
|
|
||||||
CMD ["/app/pkg/start.sh"]
|
CMD ["/app/pkg/start.sh"]
|
41
start.sh
41
start.sh
@ -24,7 +24,46 @@ BACKUP_PATH="/app/data/config.yaml.bak"
|
|||||||
if [ ! -f "$CONFIG_PATH" ]; then
|
if [ ! -f "$CONFIG_PATH" ]; then
|
||||||
echo "=> Generating example configuration"
|
echo "=> Generating example configuration"
|
||||||
# Generate config as root first, then fix permissions
|
# Generate config as root first, then fix permissions
|
||||||
/app/pkg/mautrix-whatsapp -g -c "$CONFIG_PATH" -r "$REGISTRATION_PATH"
|
/app/pkg/mautrix-whatsapp -g -c "$CONFIG_PATH" -r "$REGISTRATION_PATH" || {
|
||||||
|
echo "=> Config generation failed, creating minimal config"
|
||||||
|
cat > "$CONFIG_PATH" << 'EOF'
|
||||||
|
homeserver:
|
||||||
|
address: https://matrix.example.com
|
||||||
|
domain: example.com
|
||||||
|
|
||||||
|
appservice:
|
||||||
|
address: https://example.com
|
||||||
|
hostname: 0.0.0.0
|
||||||
|
port: 29318
|
||||||
|
database:
|
||||||
|
type: postgres
|
||||||
|
uri: postgres://user:pass@localhost/db
|
||||||
|
|
||||||
|
bridge:
|
||||||
|
username_template: whatsapp_{{.}}
|
||||||
|
displayname_template: "{{if .BusinessName}}{{.BusinessName}}{{else}}{{.PushName}}{{end}} (WA)"
|
||||||
|
|
||||||
|
logging:
|
||||||
|
handlers:
|
||||||
|
file:
|
||||||
|
filename: /app/data/logs/mautrix-whatsapp.log
|
||||||
|
EOF
|
||||||
|
cat > "$REGISTRATION_PATH" << 'EOF'
|
||||||
|
id: whatsapp
|
||||||
|
url: https://example.com
|
||||||
|
as_token: generated_token
|
||||||
|
hs_token: generated_token
|
||||||
|
rate_limited: false
|
||||||
|
sender_localpart: whatsappbot
|
||||||
|
namespaces:
|
||||||
|
users:
|
||||||
|
- exclusive: true
|
||||||
|
regex: '@whatsapp_.*:.*'
|
||||||
|
aliases:
|
||||||
|
- exclusive: true
|
||||||
|
regex: '#whatsapp_.*:.*'
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
# Configure for Cloudron environment
|
# Configure for Cloudron environment
|
||||||
if [ -n "${CLOUDRON_POSTGRESQL_URL:-}" ]; then
|
if [ -n "${CLOUDRON_POSTGRESQL_URL:-}" ]; then
|
||||||
|
Reference in New Issue
Block a user