diff --git a/.gitignore b/.gitignore index a9d43534..20dbe2c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /config.php /docker-compose.yml +/services/nginx/app/vendor/ +/services/nginx/app/modules/washcertificates/vendor/ diff --git a/Dockerfile b/Dockerfile index 2755ffd0..ac837b70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -# Base image: PHP 8.2 with Apache -FROM php:8.2-apache +# Base image: PHP 8.2 with FPM +FROM php:8.2-fpm # Install necessary system dependencies RUN apt-get update && apt-get install -y \ @@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y \ libcurl4-openssl-dev \ default-mysql-client \ redis-server \ + nginx \ && docker-php-ext-install \ mysqli \ pdo \ @@ -19,15 +20,15 @@ RUN apt-get update && apt-get install -y \ bcmath \ sockets -# Enable Apache mod_rewrite (required for web server routing) -RUN a2enmod rewrite - # Set working directory WORKDIR /var/www/html # Copy application code COPY . /var/www/html +# Copy Nginx configuration file +COPY nginx.conf /etc/nginx/nginx.conf + # Install Composer COPY --from=composer:2.6 /usr/bin/composer /usr/bin/composer @@ -37,8 +38,8 @@ RUN composer install --no-dev --optimize-autoloader # Set permissions for the web server RUN chown -R www-data:www-data /var/www/html && chmod -R 755 /var/www/html -# Expose port 80 for HTTP traffic -EXPOSE 80 +# Expose port 80 (HTTP) and 443 (HTTPS) +EXPOSE 80 443 -# Start Redis service when the container starts -CMD service redis-server start && apache2-foreground \ No newline at end of file +# Start services (Nginx and Redis) when the container starts +CMD service redis-server start && nginx -g "daemon off;" && php-fpm \ No newline at end of file diff --git a/apache-ssl.conf b/apache-ssl.conf new file mode 100644 index 00000000..26e79c26 --- /dev/null +++ b/apache-ssl.conf @@ -0,0 +1,21 @@ + + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + + SSLEngine on + SSLCertificateFile /etc/letsencrypt/live/nnks.truckwash.dk/fullchain.pem + SSLCertificateKeyFile /etc/letsencrypt/live/nnks.truckwash.dk/privkey.pem + + + SSLOptions +StdEnvVars + + + + SSLOptions +StdEnvVars + + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined + + \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..5992d36e --- /dev/null +++ b/nginx.conf @@ -0,0 +1,83 @@ +# Main Nginx Configuration File +worker_processes auto; +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + # Include additional configuration files + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Log settings + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + # Gzip settings (optional) + gzip on; + gzip_types text/plain application/xml text/css application/javascript; + + # Include server block configurations + include /etc/nginx/conf.d/*.conf; + + # Redirect HTTP to HTTPS + server { + listen 80; + server_name nnks.truckwash.dk; + + return 301 https://$host$request_uri; + } + + server { + listen 443 ssl; + server_name nnks.truckwash.dk; + + ssl_certificate /etc/letsencrypt/live/nnks.truckwash.dk/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/nnks.truckwash.dk/privkey.pem; + + root /var/www/html; + index index.html index.htm index.php; + + # Enable SSL options + ssl_protocols TLSv1.2 TLSv1.3; + ssl_prefer_server_ciphers on; + + # Logging + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log combined; + + # Add CORS headers + location / { + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; + add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With"; + add_header Access-Control-Allow-Credentials true; + + # If OPTIONS method is needed for preflight + if ($request_method = 'OPTIONS') { + add_header Access-Control-Allow-Origin *; + add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; + add_header Access-Control-Allow-Headers "Authorization, Content-Type, X-Requested-With"; + return 204; # No Content + } + + # Run the index.php file, no matter what the request URI is + try_files $uri $uri/ /index.php?$query_string; + } + + # Location for PHP (using PHP 8.2) + location ~ \.php$ { + include fastcgi_params; + fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + } + + # Location for static files + location ~* \.(cgi|shtml|phtml)$ { + # Additional SSL options or configurations can be placed here, if necessary. + } + } +} \ No newline at end of file diff --git a/services/mysql/Dockerfile b/services/mysql/Dockerfile new file mode 100644 index 00000000..b88d8421 --- /dev/null +++ b/services/mysql/Dockerfile @@ -0,0 +1,3 @@ +FROM mysql:8.0 +# Set working directory +WORKDIR /var/lib/mysql \ No newline at end of file diff --git a/services/nginx/Dockerfile b/services/nginx/Dockerfile new file mode 100644 index 00000000..0bf3de3d --- /dev/null +++ b/services/nginx/Dockerfile @@ -0,0 +1,14 @@ +# NGINX Dockerfile +FROM nginx:1.27.3-alpine + +# Import the configuration file for Nginx +COPY nginx.conf /etc/nginx/nginx.conf + +# Copy the contents of the /app directory to the /var/www/html directory +COPY /app /var/www/html + +# Expose port 80 (HTTP) and 443 (HTTPS) +EXPOSE 80 443 + +# Start Nginx when the container starts +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/.htaccess b/services/nginx/app/.htaccess similarity index 100% rename from .htaccess rename to services/nginx/app/.htaccess diff --git a/classes/authentication.php b/services/nginx/app/classes/authentication.php similarity index 100% rename from classes/authentication.php rename to services/nginx/app/classes/authentication.php diff --git a/classes/db.php b/services/nginx/app/classes/db.php similarity index 100% rename from classes/db.php rename to services/nginx/app/classes/db.php diff --git a/classes/economic.php b/services/nginx/app/classes/economic.php similarity index 100% rename from classes/economic.php rename to services/nginx/app/classes/economic.php diff --git a/classes/encrypt.php b/services/nginx/app/classes/encrypt.php similarity index 100% rename from classes/encrypt.php rename to services/nginx/app/classes/encrypt.php diff --git a/classes/language_packs.php b/services/nginx/app/classes/language_packs.php similarity index 100% rename from classes/language_packs.php rename to services/nginx/app/classes/language_packs.php diff --git a/classes/object_property.php b/services/nginx/app/classes/object_property.php similarity index 100% rename from classes/object_property.php rename to services/nginx/app/classes/object_property.php diff --git a/classes/ratelimit.php b/services/nginx/app/classes/ratelimit.php similarity index 100% rename from classes/ratelimit.php rename to services/nginx/app/classes/ratelimit.php diff --git a/classes/redis.php b/services/nginx/app/classes/redis.php similarity index 100% rename from classes/redis.php rename to services/nginx/app/classes/redis.php diff --git a/classes/request.php b/services/nginx/app/classes/request.php similarity index 100% rename from classes/request.php rename to services/nginx/app/classes/request.php diff --git a/classes/response.php b/services/nginx/app/classes/response.php similarity index 100% rename from classes/response.php rename to services/nginx/app/classes/response.php diff --git a/classes/router.php b/services/nginx/app/classes/router.php similarity index 100% rename from classes/router.php rename to services/nginx/app/classes/router.php diff --git a/classes/session.php b/services/nginx/app/classes/session.php similarity index 100% rename from classes/session.php rename to services/nginx/app/classes/session.php diff --git a/classes/slack.php b/services/nginx/app/classes/slack.php similarity index 100% rename from classes/slack.php rename to services/nginx/app/classes/slack.php diff --git a/classes/wash_certificate_store.php b/services/nginx/app/classes/wash_certificate_store.php similarity index 100% rename from classes/wash_certificate_store.php rename to services/nginx/app/classes/wash_certificate_store.php diff --git a/classes/wordpress_bookings_remote.php b/services/nginx/app/classes/wordpress_bookings_remote.php similarity index 100% rename from classes/wordpress_bookings_remote.php rename to services/nginx/app/classes/wordpress_bookings_remote.php diff --git a/cli.php b/services/nginx/app/cli.php similarity index 100% rename from cli.php rename to services/nginx/app/cli.php diff --git a/composer.json b/services/nginx/app/composer.json similarity index 100% rename from composer.json rename to services/nginx/app/composer.json diff --git a/composer.lock b/services/nginx/app/composer.lock similarity index 100% rename from composer.lock rename to services/nginx/app/composer.lock diff --git a/services/nginx/app/config.php b/services/nginx/app/config.php new file mode 100644 index 00000000..94a85a99 --- /dev/null +++ b/services/nginx/app/config.php @@ -0,0 +1,98 @@ + 'host', + 'CONFIG_DB_USER' => 'user', + 'CONFIG_DB_PASSWORD' => 'password', + 'CONFIG_DB_DATABASE' => 'database', + 'DEBUG' => 'DEBUG', + 'ENCRYPTION_KEY' => 'ENCRYPTION_KEY', + 'CORS' => 'CORS', + 'ECONOMIC_API_APP_ACCESS_GRANT' => 'app_access_grant', + 'ECONOMIC_API_APP_ACCESS_GRANT2' => 'app_access_grant2', + 'ECONOMIC_API_APP_SECRET_TOKEN' => 'app_secret_token', + 'WORDPRESS_STATIC_TOKEN' => 'WORDPRESS_STATIC_TOKEN', + 'EMAIL_WASH_CERTIFICATE_TOKEN' => 'EMAIL_WASH_CERTIFICATE_TOKEN', + 'WORDPRESS_API_URL' => 'WORDPRESS_API_URL', + 'MINIO_ENDPOINT' => 'endpoint', + 'MINIO_ACCESS_KEY' => 'access_key', + 'MINIO_SECRET_KEY' => 'secret_key', + 'SLACK_DEFAULT_WEBHOOK' => 'SLACK_DEFAULT_WEBHOOK', + 'REDIS_CONFIG_HOST' => 'host', + 'REDIS_CONFIG_DATABASE' => 'database', + 'REDIS_CONFIG_PASSWORD' => 'password' + ]; + /** + * Set the db configuration + */ + $CONFIG_DB = [ + 'host' => $_ENV['CONFIG_DB_HOST'], + 'user' => $_ENV['CONFIG_DB_USER'], + 'password' => $_ENV['CONFIG_DB_PASSWORD'], + 'database' => $_ENV['CONFIG_DB_DATABASE'] + ]; + /** + * Set the debug configuration + */ + $DEBUG = $_ENV['DEBUG']; + /** + * Set the encryption key + */ + $ENCRYPTION_KEY = $_ENV['ENCRYPTION_KEY']; + /** + * Set the CORS configuration + */ + $CORS = $_ENV['CORS']; + /** + * Set the economic API configuration + */ + $ECONOMIC_API = [ + 'app_access_grant' => $_ENV['ECONOMIC_API_APP_ACCESS_GRANT'], + 'app_access_grant2' => $_ENV['ECONOMIC_API_APP_ACCESS_GRANT2'], + 'app_secret_token' => $_ENV['ECONOMIC_API_APP_SECRET_TOKEN'] + ]; + /** + * Set the WordPress static token + */ + $WORDPRESS_STATIC_TOKEN = $_ENV['WORDPRESS_STATIC_TOKEN']; + /** + * Set the email wash certificate token + */ + $EMAIL_WASH_CERTIFICATE_TOKEN = $_ENV['EMAIL_WASH_CERTIFICATE_TOKEN']; + /** + * Set the WordPress API URL + */ + $WORDPRESS_API_URL = $_ENV['WORDPRESS_API_URL']; + /** + * Set the Minio configuration + */ + $MINIO = [ + 'endpoint' => $_ENV['MINIO_ENDPOINT'], + 'access_key' => $_ENV['MINIO_ACCESS_KEY'], + 'secret_key' => $_ENV['MINIO_SECRET_KEY'] + ]; + /** + * Set the Slack default webhook + */ + $SLACK_DEFAULT_WEBHOOK = $_ENV['SLACK_DEFAULT_WEBHOOK']; + /** + * Set the Redis configuration + */ + $REDIS_CONFIG = [ + 'host' => $_ENV['REDIS_CONFIG_HOST'], + 'database' => $_ENV['REDIS_CONFIG_DATABASE'], + 'password' => $_ENV['REDIS_CONFIG_PASSWORD'] + ]; + + // Set the timezone + date_default_timezone_set($_ENV['CONFIG_TIMEZONE']) ?? 'Europe/Copenhagen'; + +} else { + // Throw an error if the environment variables are not set + throw new Exception('Environment variables are not set'); +} \ No newline at end of file diff --git a/cron.php b/services/nginx/app/cron.php similarity index 100% rename from cron.php rename to services/nginx/app/cron.php diff --git a/cron/CheckUnfulfilledBookings.php b/services/nginx/app/cron/CheckUnfulfilledBookings.php similarity index 100% rename from cron/CheckUnfulfilledBookings.php rename to services/nginx/app/cron/CheckUnfulfilledBookings.php diff --git a/cron/ClearAllUsersEconomicCustomerDetails.php b/services/nginx/app/cron/ClearAllUsersEconomicCustomerDetails.php similarity index 100% rename from cron/ClearAllUsersEconomicCustomerDetails.php rename to services/nginx/app/cron/ClearAllUsersEconomicCustomerDetails.php diff --git a/cron/ClearAllUsersEconomicCustomerDiscounts.php b/services/nginx/app/cron/ClearAllUsersEconomicCustomerDiscounts.php similarity index 100% rename from cron/ClearAllUsersEconomicCustomerDiscounts.php rename to services/nginx/app/cron/ClearAllUsersEconomicCustomerDiscounts.php diff --git a/cron/Cron.php b/services/nginx/app/cron/Cron.php similarity index 100% rename from cron/Cron.php rename to services/nginx/app/cron/Cron.php diff --git a/cron/SyncBookings.php b/services/nginx/app/cron/SyncBookings.php similarity index 100% rename from cron/SyncBookings.php rename to services/nginx/app/cron/SyncBookings.php diff --git a/cron/SyncLogs.php b/services/nginx/app/cron/SyncLogs.php similarity index 100% rename from cron/SyncLogs.php rename to services/nginx/app/cron/SyncLogs.php diff --git a/index.php b/services/nginx/app/index.php similarity index 100% rename from index.php rename to services/nginx/app/index.php diff --git a/interfaces/authentication_i.php b/services/nginx/app/interfaces/authentication_i.php similarity index 100% rename from interfaces/authentication_i.php rename to services/nginx/app/interfaces/authentication_i.php diff --git a/interfaces/economic_i.php b/services/nginx/app/interfaces/economic_i.php similarity index 100% rename from interfaces/economic_i.php rename to services/nginx/app/interfaces/economic_i.php diff --git a/interfaces/encrypt_i.php b/services/nginx/app/interfaces/encrypt_i.php similarity index 100% rename from interfaces/encrypt_i.php rename to services/nginx/app/interfaces/encrypt_i.php diff --git a/interfaces/language_pack_i.php b/services/nginx/app/interfaces/language_pack_i.php similarity index 100% rename from interfaces/language_pack_i.php rename to services/nginx/app/interfaces/language_pack_i.php diff --git a/interfaces/minio_wash_certificates_i.php b/services/nginx/app/interfaces/minio_wash_certificates_i.php similarity index 100% rename from interfaces/minio_wash_certificates_i.php rename to services/nginx/app/interfaces/minio_wash_certificates_i.php diff --git a/interfaces/notification_i.php b/services/nginx/app/interfaces/notification_i.php similarity index 100% rename from interfaces/notification_i.php rename to services/nginx/app/interfaces/notification_i.php diff --git a/interfaces/ratelimit_i.php b/services/nginx/app/interfaces/ratelimit_i.php similarity index 100% rename from interfaces/ratelimit_i.php rename to services/nginx/app/interfaces/ratelimit_i.php diff --git a/interfaces/redis_i.php b/services/nginx/app/interfaces/redis_i.php similarity index 100% rename from interfaces/redis_i.php rename to services/nginx/app/interfaces/redis_i.php diff --git a/interfaces/response_i.php b/services/nginx/app/interfaces/response_i.php similarity index 100% rename from interfaces/response_i.php rename to services/nginx/app/interfaces/response_i.php diff --git a/interfaces/wordpress_bookings_remote_i.php b/services/nginx/app/interfaces/wordpress_bookings_remote_i.php similarity index 100% rename from interfaces/wordpress_bookings_remote_i.php rename to services/nginx/app/interfaces/wordpress_bookings_remote_i.php diff --git a/languages/language_pack_en_us.php b/services/nginx/app/languages/language_pack_en_us.php similarity index 100% rename from languages/language_pack_en_us.php rename to services/nginx/app/languages/language_pack_en_us.php diff --git a/modules/economic/customers/economicCustomers.php b/services/nginx/app/modules/economic/customers/economicCustomers.php similarity index 100% rename from modules/economic/customers/economicCustomers.php rename to services/nginx/app/modules/economic/customers/economicCustomers.php diff --git a/modules/economic/customers/economic_customer_mo.php b/services/nginx/app/modules/economic/customers/economic_customer_mo.php similarity index 100% rename from modules/economic/customers/economic_customer_mo.php rename to services/nginx/app/modules/economic/customers/economic_customer_mo.php diff --git a/modules/economic/economic_m.php b/services/nginx/app/modules/economic/economic_m.php similarity index 100% rename from modules/economic/economic_m.php rename to services/nginx/app/modules/economic/economic_m.php diff --git a/modules/economic/endpoints/economic_orders_endpoint.php b/services/nginx/app/modules/economic/endpoints/economic_orders_endpoint.php similarity index 100% rename from modules/economic/endpoints/economic_orders_endpoint.php rename to services/nginx/app/modules/economic/endpoints/economic_orders_endpoint.php diff --git a/modules/economic/endpoints/orders/economic_orders_drafts_endpoint.php b/services/nginx/app/modules/economic/endpoints/orders/economic_orders_drafts_endpoint.php similarity index 100% rename from modules/economic/endpoints/orders/economic_orders_drafts_endpoint.php rename to services/nginx/app/modules/economic/endpoints/orders/economic_orders_drafts_endpoint.php diff --git a/modules/economic/invoices/draft/economicInvoicesDrafts.php b/services/nginx/app/modules/economic/invoices/draft/economicInvoicesDrafts.php similarity index 100% rename from modules/economic/invoices/draft/economicInvoicesDrafts.php rename to services/nginx/app/modules/economic/invoices/draft/economicInvoicesDrafts.php diff --git a/modules/economic/invoices/draft/economic_invoice_draft_mo.php b/services/nginx/app/modules/economic/invoices/draft/economic_invoice_draft_mo.php similarity index 100% rename from modules/economic/invoices/draft/economic_invoice_draft_mo.php rename to services/nginx/app/modules/economic/invoices/draft/economic_invoice_draft_mo.php diff --git a/modules/economic/schemas/customers.get.schema.json b/services/nginx/app/modules/economic/schemas/customers.get.schema.json similarity index 100% rename from modules/economic/schemas/customers.get.schema.json rename to services/nginx/app/modules/economic/schemas/customers.get.schema.json diff --git a/modules/washcertificates/certificates/index.php b/services/nginx/app/modules/washcertificates/certificates/index.php similarity index 100% rename from modules/washcertificates/certificates/index.php rename to services/nginx/app/modules/washcertificates/certificates/index.php diff --git a/modules/washcertificates/composer.json b/services/nginx/app/modules/washcertificates/composer.json similarity index 100% rename from modules/washcertificates/composer.json rename to services/nginx/app/modules/washcertificates/composer.json diff --git a/modules/washcertificates/composer.lock b/services/nginx/app/modules/washcertificates/composer.lock similarity index 100% rename from modules/washcertificates/composer.lock rename to services/nginx/app/modules/washcertificates/composer.lock diff --git a/modules/washcertificates/font/courier.php b/services/nginx/app/modules/washcertificates/font/courier.php similarity index 100% rename from modules/washcertificates/font/courier.php rename to services/nginx/app/modules/washcertificates/font/courier.php diff --git a/modules/washcertificates/font/courierb.php b/services/nginx/app/modules/washcertificates/font/courierb.php similarity index 100% rename from modules/washcertificates/font/courierb.php rename to services/nginx/app/modules/washcertificates/font/courierb.php diff --git a/modules/washcertificates/font/courierbi.php b/services/nginx/app/modules/washcertificates/font/courierbi.php similarity index 100% rename from modules/washcertificates/font/courierbi.php rename to services/nginx/app/modules/washcertificates/font/courierbi.php diff --git a/modules/washcertificates/font/courieri.php b/services/nginx/app/modules/washcertificates/font/courieri.php similarity index 100% rename from modules/washcertificates/font/courieri.php rename to services/nginx/app/modules/washcertificates/font/courieri.php diff --git a/modules/washcertificates/font/helvetica.php b/services/nginx/app/modules/washcertificates/font/helvetica.php similarity index 100% rename from modules/washcertificates/font/helvetica.php rename to services/nginx/app/modules/washcertificates/font/helvetica.php diff --git a/modules/washcertificates/font/helveticab.php b/services/nginx/app/modules/washcertificates/font/helveticab.php similarity index 100% rename from modules/washcertificates/font/helveticab.php rename to services/nginx/app/modules/washcertificates/font/helveticab.php diff --git a/modules/washcertificates/font/helveticabi.php b/services/nginx/app/modules/washcertificates/font/helveticabi.php similarity index 100% rename from modules/washcertificates/font/helveticabi.php rename to services/nginx/app/modules/washcertificates/font/helveticabi.php diff --git a/modules/washcertificates/font/helveticai.php b/services/nginx/app/modules/washcertificates/font/helveticai.php similarity index 100% rename from modules/washcertificates/font/helveticai.php rename to services/nginx/app/modules/washcertificates/font/helveticai.php diff --git a/modules/washcertificates/font/symbol.php b/services/nginx/app/modules/washcertificates/font/symbol.php similarity index 100% rename from modules/washcertificates/font/symbol.php rename to services/nginx/app/modules/washcertificates/font/symbol.php diff --git a/modules/washcertificates/font/times.php b/services/nginx/app/modules/washcertificates/font/times.php similarity index 100% rename from modules/washcertificates/font/times.php rename to services/nginx/app/modules/washcertificates/font/times.php diff --git a/modules/washcertificates/font/timesb.php b/services/nginx/app/modules/washcertificates/font/timesb.php similarity index 100% rename from modules/washcertificates/font/timesb.php rename to services/nginx/app/modules/washcertificates/font/timesb.php diff --git a/modules/washcertificates/font/timesbi.php b/services/nginx/app/modules/washcertificates/font/timesbi.php similarity index 100% rename from modules/washcertificates/font/timesbi.php rename to services/nginx/app/modules/washcertificates/font/timesbi.php diff --git a/modules/washcertificates/font/timesi.php b/services/nginx/app/modules/washcertificates/font/timesi.php similarity index 100% rename from modules/washcertificates/font/timesi.php rename to services/nginx/app/modules/washcertificates/font/timesi.php diff --git a/modules/washcertificates/font/zapfdingbats.php b/services/nginx/app/modules/washcertificates/font/zapfdingbats.php similarity index 100% rename from modules/washcertificates/font/zapfdingbats.php rename to services/nginx/app/modules/washcertificates/font/zapfdingbats.php diff --git a/modules/washcertificates/images/truckwash-banner-png.png b/services/nginx/app/modules/washcertificates/images/truckwash-banner-png.png similarity index 100% rename from modules/washcertificates/images/truckwash-banner-png.png rename to services/nginx/app/modules/washcertificates/images/truckwash-banner-png.png diff --git a/modules/washcertificates/images/truckwash-underskrift.png b/services/nginx/app/modules/washcertificates/images/truckwash-underskrift.png similarity index 100% rename from modules/washcertificates/images/truckwash-underskrift.png rename to services/nginx/app/modules/washcertificates/images/truckwash-underskrift.png diff --git a/modules/washcertificates/index.php b/services/nginx/app/modules/washcertificates/index.php similarity index 100% rename from modules/washcertificates/index.php rename to services/nginx/app/modules/washcertificates/index.php diff --git a/modules/washcertificates/output/certificates/wash_certificate.xlsx b/services/nginx/app/modules/washcertificates/output/certificates/wash_certificate.xlsx similarity index 100% rename from modules/washcertificates/output/certificates/wash_certificate.xlsx rename to services/nginx/app/modules/washcertificates/output/certificates/wash_certificate.xlsx diff --git a/modules/washcertificates/templates/template2024julv3.xlsx b/services/nginx/app/modules/washcertificates/templates/template2024julv3.xlsx similarity index 100% rename from modules/washcertificates/templates/template2024julv3.xlsx rename to services/nginx/app/modules/washcertificates/templates/template2024julv3.xlsx diff --git a/modules/washcertificates/twc_spreadsheet_class.php b/services/nginx/app/modules/washcertificates/twc_spreadsheet_class.php similarity index 100% rename from modules/washcertificates/twc_spreadsheet_class.php rename to services/nginx/app/modules/washcertificates/twc_spreadsheet_class.php diff --git a/objects/bookings_o.php b/services/nginx/app/objects/bookings_o.php similarity index 100% rename from objects/bookings_o.php rename to services/nginx/app/objects/bookings_o.php diff --git a/objects/cron_o.php b/services/nginx/app/objects/cron_o.php similarity index 100% rename from objects/cron_o.php rename to services/nginx/app/objects/cron_o.php diff --git a/objects/customer_codes_o.php b/services/nginx/app/objects/customer_codes_o.php similarity index 100% rename from objects/customer_codes_o.php rename to services/nginx/app/objects/customer_codes_o.php diff --git a/objects/customer_notes_o.php b/services/nginx/app/objects/customer_notes_o.php similarity index 100% rename from objects/customer_notes_o.php rename to services/nginx/app/objects/customer_notes_o.php diff --git a/objects/customer_vehicles_o.php b/services/nginx/app/objects/customer_vehicles_o.php similarity index 100% rename from objects/customer_vehicles_o.php rename to services/nginx/app/objects/customer_vehicles_o.php diff --git a/objects/departments_o.php b/services/nginx/app/objects/departments_o.php similarity index 100% rename from objects/departments_o.php rename to services/nginx/app/objects/departments_o.php diff --git a/objects/economic_module_orders.php b/services/nginx/app/objects/economic_module_orders.php similarity index 100% rename from objects/economic_module_orders.php rename to services/nginx/app/objects/economic_module_orders.php diff --git a/objects/logs_o.php b/services/nginx/app/objects/logs_o.php similarity index 100% rename from objects/logs_o.php rename to services/nginx/app/objects/logs_o.php diff --git a/objects/order_items_o.php b/services/nginx/app/objects/order_items_o.php similarity index 100% rename from objects/order_items_o.php rename to services/nginx/app/objects/order_items_o.php diff --git a/objects/orders_o.php b/services/nginx/app/objects/orders_o.php similarity index 100% rename from objects/orders_o.php rename to services/nginx/app/objects/orders_o.php diff --git a/objects/plate_scanners_o.php b/services/nginx/app/objects/plate_scanners_o.php similarity index 100% rename from objects/plate_scanners_o.php rename to services/nginx/app/objects/plate_scanners_o.php diff --git a/objects/plate_scans_o.php b/services/nginx/app/objects/plate_scans_o.php similarity index 100% rename from objects/plate_scans_o.php rename to services/nginx/app/objects/plate_scans_o.php diff --git a/objects/products_o.php b/services/nginx/app/objects/products_o.php similarity index 100% rename from objects/products_o.php rename to services/nginx/app/objects/products_o.php diff --git a/objects/ratelimit_o.php b/services/nginx/app/objects/ratelimit_o.php similarity index 100% rename from objects/ratelimit_o.php rename to services/nginx/app/objects/ratelimit_o.php diff --git a/objects/tokens_o.php b/services/nginx/app/objects/tokens_o.php similarity index 100% rename from objects/tokens_o.php rename to services/nginx/app/objects/tokens_o.php diff --git a/objects/user_key_value_pairs_o.php b/services/nginx/app/objects/user_key_value_pairs_o.php similarity index 100% rename from objects/user_key_value_pairs_o.php rename to services/nginx/app/objects/user_key_value_pairs_o.php diff --git a/objects/user_price_overrides_o.php b/services/nginx/app/objects/user_price_overrides_o.php similarity index 100% rename from objects/user_price_overrides_o.php rename to services/nginx/app/objects/user_price_overrides_o.php diff --git a/objects/users_o.php b/services/nginx/app/objects/users_o.php similarity index 100% rename from objects/users_o.php rename to services/nginx/app/objects/users_o.php diff --git a/routes/authRoute.php b/services/nginx/app/routes/authRoute.php similarity index 100% rename from routes/authRoute.php rename to services/nginx/app/routes/authRoute.php diff --git a/routes/bookingsRoute.php b/services/nginx/app/routes/bookingsRoute.php similarity index 100% rename from routes/bookingsRoute.php rename to services/nginx/app/routes/bookingsRoute.php diff --git a/routes/cronRoute.php b/services/nginx/app/routes/cronRoute.php similarity index 100% rename from routes/cronRoute.php rename to services/nginx/app/routes/cronRoute.php diff --git a/routes/customerAttributes.php b/services/nginx/app/routes/customerAttributes.php similarity index 100% rename from routes/customerAttributes.php rename to services/nginx/app/routes/customerAttributes.php diff --git a/routes/customerCodeDepartmentRoute.php b/services/nginx/app/routes/customerCodeDepartmentRoute.php similarity index 100% rename from routes/customerCodeDepartmentRoute.php rename to services/nginx/app/routes/customerCodeDepartmentRoute.php diff --git a/routes/customerNotes.php b/services/nginx/app/routes/customerNotes.php similarity index 100% rename from routes/customerNotes.php rename to services/nginx/app/routes/customerNotes.php diff --git a/routes/customerSearchRoute.php b/services/nginx/app/routes/customerSearchRoute.php similarity index 100% rename from routes/customerSearchRoute.php rename to services/nginx/app/routes/customerSearchRoute.php diff --git a/routes/departmentsRoute.php b/services/nginx/app/routes/departmentsRoute.php similarity index 100% rename from routes/departmentsRoute.php rename to services/nginx/app/routes/departmentsRoute.php diff --git a/routes/economicInvoiceRoute.php b/services/nginx/app/routes/economicInvoiceRoute.php similarity index 100% rename from routes/economicInvoiceRoute.php rename to services/nginx/app/routes/economicInvoiceRoute.php diff --git a/routes/exampleRoute.php b/services/nginx/app/routes/exampleRoute.php similarity index 100% rename from routes/exampleRoute.php rename to services/nginx/app/routes/exampleRoute.php diff --git a/routes/intimidateRoute.php b/services/nginx/app/routes/intimidateRoute.php similarity index 100% rename from routes/intimidateRoute.php rename to services/nginx/app/routes/intimidateRoute.php diff --git a/routes/optionsRoute.php b/services/nginx/app/routes/optionsRoute.php similarity index 100% rename from routes/optionsRoute.php rename to services/nginx/app/routes/optionsRoute.php diff --git a/routes/orderItemsRoute.php b/services/nginx/app/routes/orderItemsRoute.php similarity index 100% rename from routes/orderItemsRoute.php rename to services/nginx/app/routes/orderItemsRoute.php diff --git a/routes/orderRoute.php b/services/nginx/app/routes/orderRoute.php similarity index 100% rename from routes/orderRoute.php rename to services/nginx/app/routes/orderRoute.php diff --git a/routes/ordersRoute.php b/services/nginx/app/routes/ordersRoute.php similarity index 100% rename from routes/ordersRoute.php rename to services/nginx/app/routes/ordersRoute.php diff --git a/routes/plateScannersRoute.php b/services/nginx/app/routes/plateScannersRoute.php similarity index 100% rename from routes/plateScannersRoute.php rename to services/nginx/app/routes/plateScannersRoute.php diff --git a/routes/plateScansRoute.php b/services/nginx/app/routes/plateScansRoute.php similarity index 100% rename from routes/plateScansRoute.php rename to services/nginx/app/routes/plateScansRoute.php diff --git a/routes/productsRoute.php b/services/nginx/app/routes/productsRoute.php similarity index 100% rename from routes/productsRoute.php rename to services/nginx/app/routes/productsRoute.php diff --git a/routes/sessionRoute.php b/services/nginx/app/routes/sessionRoute.php similarity index 100% rename from routes/sessionRoute.php rename to services/nginx/app/routes/sessionRoute.php diff --git a/routes/superuserDepartmentRoute.php b/services/nginx/app/routes/superuserDepartmentRoute.php similarity index 100% rename from routes/superuserDepartmentRoute.php rename to services/nginx/app/routes/superuserDepartmentRoute.php diff --git a/routes/userOrdersRoute.php b/services/nginx/app/routes/userOrdersRoute.php similarity index 100% rename from routes/userOrdersRoute.php rename to services/nginx/app/routes/userOrdersRoute.php diff --git a/routes/userRoute.php b/services/nginx/app/routes/userRoute.php similarity index 100% rename from routes/userRoute.php rename to services/nginx/app/routes/userRoute.php diff --git a/routes/usersRoute.php b/services/nginx/app/routes/usersRoute.php similarity index 100% rename from routes/usersRoute.php rename to services/nginx/app/routes/usersRoute.php diff --git a/routes/vehiclePlateLastOrdersRoute.php b/services/nginx/app/routes/vehiclePlateLastOrdersRoute.php similarity index 100% rename from routes/vehiclePlateLastOrdersRoute.php rename to services/nginx/app/routes/vehiclePlateLastOrdersRoute.php diff --git a/routes/vehiclesRoute.php b/services/nginx/app/routes/vehiclesRoute.php similarity index 100% rename from routes/vehiclesRoute.php rename to services/nginx/app/routes/vehiclesRoute.php diff --git a/routes/workerRoute.php b/services/nginx/app/routes/workerRoute.php similarity index 100% rename from routes/workerRoute.php rename to services/nginx/app/routes/workerRoute.php diff --git a/services/nginx/app/tests/HTTP/numberplatescans.http b/services/nginx/app/tests/HTTP/numberplatescans.http new file mode 100644 index 00000000..c9f2f47a --- /dev/null +++ b/services/nginx/app/tests/HTTP/numberplatescans.http @@ -0,0 +1,9 @@ +### POST /numberplatescans +POST /numberplatescans HTTP/1.1 +Host: truckwashdev.maintenancemode.cloud +Authorization: Bearer 2d9cc49436b716c69abb39e152f0024e6a64734d131d77eb4f87b5b5aeb542fd +Content-Type: application/json + +{ + "plate": "AB123" +} \ No newline at end of file diff --git a/tests/bookingModule/BookingModuleTest.php b/services/nginx/app/tests/bookingModule/BookingModuleTest.php similarity index 100% rename from tests/bookingModule/BookingModuleTest.php rename to services/nginx/app/tests/bookingModule/BookingModuleTest.php diff --git a/tests/bookingModule/bookingSyncTest.php b/services/nginx/app/tests/bookingModule/bookingSyncTest.php similarity index 100% rename from tests/bookingModule/bookingSyncTest.php rename to services/nginx/app/tests/bookingModule/bookingSyncTest.php diff --git a/tests/economicOrderParser/economicOrderParserTest.php b/services/nginx/app/tests/economicOrderParser/economicOrderParserTest.php similarity index 100% rename from tests/economicOrderParser/economicOrderParserTest.php rename to services/nginx/app/tests/economicOrderParser/economicOrderParserTest.php diff --git a/tests/minio/minioTest.php b/services/nginx/app/tests/minio/minioTest.php similarity index 100% rename from tests/minio/minioTest.php rename to services/nginx/app/tests/minio/minioTest.php diff --git a/tests/minio/testUpload.txt b/services/nginx/app/tests/minio/testUpload.txt similarity index 100% rename from tests/minio/testUpload.txt rename to services/nginx/app/tests/minio/testUpload.txt diff --git a/tests/redis/redisLogSyncTest.php b/services/nginx/app/tests/redis/redisLogSyncTest.php similarity index 100% rename from tests/redis/redisLogSyncTest.php rename to services/nginx/app/tests/redis/redisLogSyncTest.php diff --git a/tests/redis/redisTest.php b/services/nginx/app/tests/redis/redisTest.php similarity index 100% rename from tests/redis/redisTest.php rename to services/nginx/app/tests/redis/redisTest.php diff --git a/tests/slackModule/SlackModuleTest.php b/services/nginx/app/tests/slackModule/SlackModuleTest.php similarity index 100% rename from tests/slackModule/SlackModuleTest.php rename to services/nginx/app/tests/slackModule/SlackModuleTest.php diff --git a/traits/db_object_t.php b/services/nginx/app/traits/db_object_t.php similarity index 100% rename from traits/db_object_t.php rename to services/nginx/app/traits/db_object_t.php diff --git a/traits/economic_endpoint_t.php b/services/nginx/app/traits/economic_endpoint_t.php similarity index 100% rename from traits/economic_endpoint_t.php rename to services/nginx/app/traits/economic_endpoint_t.php diff --git a/traits/language_pack_t.php b/services/nginx/app/traits/language_pack_t.php similarity index 100% rename from traits/language_pack_t.php rename to services/nginx/app/traits/language_pack_t.php diff --git a/traits/minio_t.php b/services/nginx/app/traits/minio_t.php similarity index 100% rename from traits/minio_t.php rename to services/nginx/app/traits/minio_t.php diff --git a/traits/notification_t.php b/services/nginx/app/traits/notification_t.php similarity index 100% rename from traits/notification_t.php rename to services/nginx/app/traits/notification_t.php diff --git a/traits/redis_t.php b/services/nginx/app/traits/redis_t.php similarity index 100% rename from traits/redis_t.php rename to services/nginx/app/traits/redis_t.php diff --git a/traits/route_t.php b/services/nginx/app/traits/route_t.php similarity index 100% rename from traits/route_t.php rename to services/nginx/app/traits/route_t.php diff --git a/traits/session_t.php b/services/nginx/app/traits/session_t.php similarity index 100% rename from traits/session_t.php rename to services/nginx/app/traits/session_t.php diff --git a/traits/wordpress_api_object_t.php b/services/nginx/app/traits/wordpress_api_object_t.php similarity index 100% rename from traits/wordpress_api_object_t.php rename to services/nginx/app/traits/wordpress_api_object_t.php diff --git a/services/nginx/nginx.conf b/services/nginx/nginx.conf new file mode 100644 index 00000000..483dbc0a --- /dev/null +++ b/services/nginx/nginx.conf @@ -0,0 +1,76 @@ +# Main Nginx Configuration File +worker_processes auto; +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + # Include additional configuration files + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Log settings + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + # Gzip settings (optional) + gzip on; + gzip_types text/plain application/xml text/css application/javascript; + + # Include server block configurations + include /etc/nginx/conf.d/*.conf; + + # Redirect HTTP to HTTPS + server { + listen 80; + server_name nnks.truckwash.dk; + + return 301 https://$host$request_uri; + } + + server { + listen 443 ssl; + server_name nnks.truckwash.dk; + + + # SSL certificates + ssl_certificate /etc/letsencrypt/live/nnks.truckwash.dk/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/nnks.truckwash.dk/privkey.pem; + + # Enable SSL options + ssl_protocols TLSv1.2 TLSv1.3; + ssl_prefer_server_ciphers on; + + # Logging + error_log /var/log/nginx/error.log; + access_log /var/log/nginx/access.log combined; + + # Index file + index index.php index.html index.htm; + + # Root directory (public- uses index.php) + root /var/www/html; + + # Location block for PHP files + + + location ^~ / { + include fastcgi_params; + fastcgi_pass php:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME index.php; + } + + # Deny access to .htaccess files + location ~ /\.ht { + deny all; + } + + # Deny access to hidden files + location ~ /\. { + deny all; + } + } +} \ No newline at end of file diff --git a/services/php/Dockerfile b/services/php/Dockerfile new file mode 100644 index 00000000..a5e338da --- /dev/null +++ b/services/php/Dockerfile @@ -0,0 +1,36 @@ +# Use the official PHP 8.2 image with Apache disabled +FROM php:8.2-fpm + +# Set the working directory inside the container +WORKDIR /var/www/html + +# Install Composer globally +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + + +# Install required extensions and dependencies +RUN apt-get update && apt-get install -y \ + libpng-dev \ + libonig-dev \ + libxml2-dev \ + zip \ + unzip \ + git \ + curl \ + && docker-php-ext-install mbstring exif pcntl bcmath gd pdo_mysql mysqli + +# Copy application files into the container +COPY /nginx/app /var/www/html + +# Set the appropriate permissions for the working directory +RUN chown -R www-data:www-data /var/www/html \ + && chmod -R 755 /var/www/html + +# Install using Composer +RUN composer install --no-dev + +# Expose port 9000 +EXPOSE 9000 + +# Start PHP-FPM when the container starts +CMD ["php-fpm"] \ No newline at end of file diff --git a/services/redis/Dockerfile b/services/redis/Dockerfile new file mode 100644 index 00000000..8a156407 --- /dev/null +++ b/services/redis/Dockerfile @@ -0,0 +1,19 @@ +FROM redis:latest + +# Import the Redis configuration file +COPY redis.conf /etc/redis/redis.conf + +# Append the password from the REDIS_PASSWORD environment variable to the Redis configuration file +ARG REDIS_PASSWORD=default_password +# If the password is the default password, show a warning message +RUN if [ "$REDIS_PASSWORD" = "default_password" ]; then echo "WARNING: Using the default password for Redis. Please set the REDIS_PASSWORD environment variable."; fi +# Append the password to the Redis configuration file if it is not the default password +RUN if [ "$REDIS_PASSWORD" != "default_password" ]; then echo "requirepass $REDIS_PASSWORD" >> /etc/redis/redis.conf; fi +# Set the working directory inside the container +WORKDIR /data + +# Expose port 6379 +EXPOSE 6379 + +# Start Redis when the container starts +CMD redis-server /etc/redis/redis.conf \ No newline at end of file diff --git a/services/redis/redis.conf b/services/redis/redis.conf new file mode 100644 index 00000000..e69de29b