Skip to content
This repository was archived by the owner on Sep 1, 2025. It is now read-only.

Commit 2f4590b

Browse files
committed
[Fix]: AutoSSL issues , removed temporary and docker setup works with http only
1 parent d3455fb commit 2f4590b

File tree

5 files changed

+88
-416
lines changed

5 files changed

+88
-416
lines changed

.env.example

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ APP_ENV=production
1111
# Debug mode: enable only for development
1212
APP_DEBUG=false
1313

14-
# Application URL (with protocol)
15-
APP_URL=https://your-domain.com
14+
# Application URL
15+
APP_URL=http://localhost
1616

17-
# Application domain (without protocol)
18-
APP_DOMAIN=your-domain.com
17+
# Application domain
18+
APP_DOMAIN=localhost
1919

2020
# Timezone (see: https://www.php.net/manual/en/timezones.php)
2121
APP_TIMEZONE=UTC
@@ -35,10 +35,15 @@ DB_PORT=3306
3535
# Security Configuration
3636
# ==============================================================================
3737

38-
# Session settings
38+
# Session settings (HTTP only)
3939
SESSION_LIFETIME=0
40-
SESSION_SECURE=true
41-
SESSION_SAMESITE=Strict
40+
SESSION_SECURE=false
41+
SESSION_SAMESITE=Lax
42+
43+
# NOTE: ENABLE THIS IF YOU ARE USING HTTPS
44+
# SESSION_SECURE=true
45+
# SESSION_SAMESITE=Strict
46+
4247

4348
# Session encryption key (generate a random 32-character string)
4449
SESSION_KEY=CHANGE_THIS_32_CHARACTER_SESSION_KEY
@@ -77,15 +82,14 @@ LOG_MAX_FILES=10
7782
# Docker Configuration
7883
# ==============================================================================
7984

80-
# Default admin user credentials (Docker version)
81-
ADMIN_EMAIL=admin@your-domain.com
82-
ADMIN_PASSWORD=CHANGE_THIS_ADMIN_PASSWORD
85+
# Default admin user credentials
86+
ADMIN_EMAIL=admin@example.com
87+
ADMIN_PASSWORD=123456789
8388
# Docker Compose project name
8489
COMPOSE_PROJECT_NAME=accounting_panel
8590

86-
# Port configuration for Docker services
91+
# Port configuration for Docker services (HTTP only)
8792
HTTP_PORT=80
88-
HTTPS_PORT=443
8993
PHPMYADMIN_PORT=8080
9094
DB_PORT_EXPOSE=3306
9195
# Database root password (for administration in docker)

Dockerfile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,15 @@ RUN composer dump-autoload --optimize --no-dev
9393
RUN echo '#!/bin/bash' > /usr/local/bin/start-app.sh \
9494
&& echo 'set -e' >> /usr/local/bin/start-app.sh \
9595
&& echo '' >> /usr/local/bin/start-app.sh \
96-
&& echo '# Wait for database' >> /usr/local/bin/start-app.sh \
97-
&& echo 'echo "Waiting for database connection..."' >> /usr/local/bin/start-app.sh \
98-
&& echo 'until mariadb -h"$DB_HOST" -u"$DB_USER" -p"$DB_PASS" "$DB_NAME" --skip-ssl -e "SELECT 1;" >/dev/null 2>&1; do' >> /usr/local/bin/start-app.sh \
99-
&& echo ' echo "Database not ready. Trying: mariadb -h$DB_HOST -u$DB_USER -p[HIDDEN] $DB_NAME --skip-ssl"' >> /usr/local/bin/start-app.sh \
100-
&& echo ' mariadb -h"$DB_HOST" -u"$DB_USER" -p"$DB_PASS" "$DB_NAME" --skip-ssl -e "SELECT 1;" 2>&1 | head -3' >> /usr/local/bin/start-app.sh \
101-
&& echo ' echo "^ If you see access denied error, run: docker compose down -v && docker compose up -d"' >> /usr/local/bin/start-app.sh \
102-
&& echo ' echo "Waiting 2 seconds..."' >> /usr/local/bin/start-app.sh \
103-
&& echo ' sleep 2' >> /usr/local/bin/start-app.sh \
104-
&& echo 'done' >> /usr/local/bin/start-app.sh \
105-
&& echo 'echo "Database connected successfully!"' >> /usr/local/bin/start-app.sh \
96+
&& echo '# Setup database user (MariaDB healthcheck ensures DB is fully ready)' >> /usr/local/bin/start-app.sh \
97+
&& echo 'echo "Setting up application database user..."' >> /usr/local/bin/start-app.sh \
98+
&& echo '# Create application user if needed (database already exists from healthcheck)' >> /usr/local/bin/start-app.sh \
99+
&& echo 'mariadb -h"$DB_HOST" -uroot -p"$DB_ROOT_PASSWORD" --skip-ssl << EOF' >> /usr/local/bin/start-app.sh \
100+
&& echo 'CREATE USER IF NOT EXISTS '\''$DB_USER'\''@'\''%'\'' IDENTIFIED BY '\''$DB_PASS'\'';' >> /usr/local/bin/start-app.sh \
101+
&& echo 'GRANT ALL PRIVILEGES ON \`$DB_NAME\`.* TO '\''$DB_USER'\''@'\''%'\'';' >> /usr/local/bin/start-app.sh \
102+
&& echo 'FLUSH PRIVILEGES;' >> /usr/local/bin/start-app.sh \
103+
&& echo 'EOF' >> /usr/local/bin/start-app.sh \
104+
&& echo 'echo "✓ Application user configured"' >> /usr/local/bin/start-app.sh \
106105
&& echo '' >> /usr/local/bin/start-app.sh \
107106
&& echo '# Ensure proper permissions on critical directories' >> /usr/local/bin/start-app.sh \
108107
&& echo 'echo "Fixing permissions..."' >> /usr/local/bin/start-app.sh \

docker-compose.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ services:
2222
ports:
2323
- "${DB_PORT_EXPOSE:-3306}:3306"
2424
healthcheck:
25-
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
25+
# Simple but reliable check: wait for MariaDB to accept connections
26+
# Database and user creation happens automatically during container initialization
27+
test: ["CMD-SHELL", "mariadb -u root -p$$MYSQL_ROOT_PASSWORD --skip-ssl -e 'SELECT 1;' >/dev/null 2>&1"]
2628
start_period: 30s
2729
interval: 10s
2830
timeout: 10s
29-
retries: 5
31+
retries: 10
3032
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --bind-address=0.0.0.0
3133

3234
# PHP-FPM Application
@@ -82,11 +84,12 @@ services:
8284
networks:
8385
- accounting_network
8486
healthcheck:
85-
test: ["CMD-SHELL", "pidof php-fpm > /dev/null || exit 1"]
87+
# Verify both PHP-FPM and database connectivity with application user
88+
test: ["CMD-SHELL", "pidof php-fpm > /dev/null && mariadb -h$$DB_HOST -u$$DB_USER -p$$DB_PASS $$DB_NAME --skip-ssl -e 'SELECT 1;' >/dev/null 2>&1"]
8689
interval: 30s
87-
timeout: 10s
90+
timeout: 15s
8891
retries: 3
89-
start_period: 60s
92+
start_period: 90s
9093

9194
# Caddy Web Server
9295
caddy:
@@ -98,12 +101,10 @@ services:
98101
condition: service_healthy
99102
ports:
100103
- "${HTTP_PORT:-80}:80"
101-
- "${HTTPS_PORT:-443}:443"
102104
env_file:
103105
- .env
104106
volumes:
105107
- ./docker/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
106-
- ./docker/caddy/ssl:/etc/caddy/ssl:ro
107108
- ./public:/var/www/html/public:ro
108109
- caddy_data:/data
109110
- caddy_config:/config

docker/caddy/Caddyfile

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,16 @@
1-
# Caddy Configuration for PersonalAccounter
2-
# This is the default configuration for development/manual setup
3-
# The setup.sh script will replace this with domain-specific configuration
4-
51
{
62
admin off
7-
local_certs
3+
# No SSL - HTTP only for simplicity
84
}
95

10-
# HTTP server - works on both ports 80 and 8080
6+
# HTTP server - localhost only, no SSL complexity
117
:80, :8080 {
128
root * /var/www/html/public
139

14-
# Security headers
15-
header {
16-
X-Content-Type-Options nosniff
17-
X-Frame-Options DENY
18-
-Server
19-
}
20-
21-
# Enable file server
22-
file_server
23-
24-
# Enable gzip compression
25-
encode gzip
26-
27-
# PHP handling
28-
php_fastcgi app:9000
29-
}
30-
31-
# HTTPS server - default port 443 and 8443 with self-signed certificate
32-
:443, :8443 {
33-
root * /var/www/html/public
34-
35-
# Self-signed TLS certificate for development/testing
36-
# Note: setup.sh will configure proper Let's Encrypt or domain-specific SSL
37-
tls internal
38-
39-
# Security headers
10+
# Security headers (HTTP only)
4011
header {
4112
X-Content-Type-Options nosniff
4213
X-Frame-Options DENY
43-
Strict-Transport-Security "max-age=31536000; includeSubDomains"
4414
-Server
4515
}
4616

0 commit comments

Comments
 (0)