Refactor: migrate files

This commit is contained in:
Jepp9350
2025-01-29 14:27:44 +01:00
parent 4c74dd7995
commit 707df910b0
142 changed files with 371 additions and 9 deletions
+2
View File
@@ -1,2 +1,4 @@
/config.php /config.php
/docker-compose.yml /docker-compose.yml
/services/nginx/app/vendor/
/services/nginx/app/modules/washcertificates/vendor/
+10 -9
View File
@@ -1,5 +1,5 @@
# Base image: PHP 8.2 with Apache # Base image: PHP 8.2 with FPM
FROM php:8.2-apache FROM php:8.2-fpm
# Install necessary system dependencies # Install necessary system dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
@@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y \
libcurl4-openssl-dev \ libcurl4-openssl-dev \
default-mysql-client \ default-mysql-client \
redis-server \ redis-server \
nginx \
&& docker-php-ext-install \ && docker-php-ext-install \
mysqli \ mysqli \
pdo \ pdo \
@@ -19,15 +20,15 @@ RUN apt-get update && apt-get install -y \
bcmath \ bcmath \
sockets sockets
# Enable Apache mod_rewrite (required for web server routing)
RUN a2enmod rewrite
# Set working directory # Set working directory
WORKDIR /var/www/html WORKDIR /var/www/html
# Copy application code # Copy application code
COPY . /var/www/html COPY . /var/www/html
# Copy Nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf
# Install Composer # Install Composer
COPY --from=composer:2.6 /usr/bin/composer /usr/bin/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 # Set permissions for the web server
RUN chown -R www-data:www-data /var/www/html && chmod -R 755 /var/www/html RUN chown -R www-data:www-data /var/www/html && chmod -R 755 /var/www/html
# Expose port 80 for HTTP traffic # Expose port 80 (HTTP) and 443 (HTTPS)
EXPOSE 80 EXPOSE 80 443
# Start Redis service when the container starts # Start services (Nginx and Redis) when the container starts
CMD service redis-server start && apache2-foreground CMD service redis-server start && nginx -g "daemon off;" && php-fpm
+21
View File
@@ -0,0 +1,21 @@
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
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
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
</VirtualHost>
</IfModule>
+83
View File
@@ -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.
}
}
}
+3
View File
@@ -0,0 +1,3 @@
FROM mysql:8.0
# Set working directory
WORKDIR /var/lib/mysql
+14
View File
@@ -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;"]
View File
+98
View File
@@ -0,0 +1,98 @@
<?php global $CONFIG_DB, $DEBUG, $ENCRYPTION_KEY, $CORS, $ECONOMIC_API, $WORDPRESS_STATIC_TOKEN, $EMAIL_WASH_CERTIFICATE_TOKEN, $MINIO, $REDIS_CONFIG, $WORDPRESS_API_URL, $SLACK_DEFAULT_WEBHOOK;
/**
* Check if the environment variables are set (If we are running in a Docker container)
*/
if (isset($_ENV['USE_ENV']) && $_ENV['USE_ENV'] === 'true') {
// Set the configuration from the environment variables
$ENV_VARIABLES = [
'CONFIG_DB_HOST' => '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');
}

Before

Width:  |  Height:  |  Size: 204 KiB

After

Width:  |  Height:  |  Size: 204 KiB

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Some files were not shown because too many files have changed in this diff Show More