feat: update Docker configuration
Removed version specification from docker-compose.yml and added mysqli extension installation in Dockerfile.
This commit is contained in:
19
compose-env-redis/docker-compose.yml
Normal file
19
compose-env-redis/docker-compose.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis:7.2-alpine
|
||||||
|
container_name: laravel_redis
|
||||||
|
command:
|
||||||
|
- redis-server
|
||||||
|
- --maxmemory 300mb
|
||||||
|
- --maxmemory-policy allkeys-lru
|
||||||
|
- --requirepass 1234567890 # Change to strong password
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:6379:6379" # Bind only to localhost
|
||||||
|
volumes:
|
||||||
|
- /Volumes/HDD_MINI/dev_docker/docker_redis:/data
|
||||||
|
restart: unless-stopped
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "redis-cli", "--no-auth-warning", "-a", "1234567890", "ping"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
3
compose-env-redis/redis.conf
Normal file
3
compose-env-redis/redis.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# redis.conf
|
||||||
|
maxmemory 250mb
|
||||||
|
maxmemory-policy volatile-lru
|
||||||
@@ -14,6 +14,10 @@ RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private
|
|||||||
|
|
||||||
RUN a2enmod rewrite
|
RUN a2enmod rewrite
|
||||||
|
|
||||||
|
# Instala la extensión mysqli
|
||||||
|
# docker-php-ext-install se encarga de compilar y habilitar la extensión.
|
||||||
|
RUN docker-php-ext-install mysqli
|
||||||
|
|
||||||
#Ejecuta comando referente a la instalacion de ssl
|
#Ejecuta comando referente a la instalacion de ssl
|
||||||
RUN a2ensite default-ssl
|
RUN a2ensite default-ssl
|
||||||
RUN a2enmod ssl
|
RUN a2enmod ssl
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
website:
|
website:
|
||||||
build:
|
build:
|
||||||
|
|||||||
297
dockerfile-php-sql-2008/Dockerfile
Normal file
297
dockerfile-php-sql-2008/Dockerfile
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
FROM php:8.3.4-fpm-bullseye
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
libpng-dev \
|
||||||
|
libonig-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
zip \
|
||||||
|
unzip \
|
||||||
|
libzip-dev \
|
||||||
|
libfreetype6-dev \
|
||||||
|
libjpeg62-turbo-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
libicu-dev \
|
||||||
|
supervisor \
|
||||||
|
nginx \
|
||||||
|
gnupg2 \
|
||||||
|
apt-transport-https \
|
||||||
|
ca-certificates \
|
||||||
|
lsb-release \
|
||||||
|
software-properties-common \
|
||||||
|
unixodbc-dev \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Add Microsoft repository and install ODBC driver 17
|
||||||
|
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
|
||||||
|
&& curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list \
|
||||||
|
&& apt-get update \
|
||||||
|
&& ACCEPT_EULA=Y apt-get install -y msodbcsql17 mssql-tools \
|
||||||
|
&& echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Configure OpenSSL to allow TLS 1.0 and 1.1 for SQL Server 2008 compatibility
|
||||||
|
RUN echo "openssl_conf = openssl_init" > /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "[openssl_init]" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "ssl_conf = ssl_sect" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "[ssl_sect]" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "system_default = system_default_sect" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "[system_default_sect]" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "MinProtocol = TLSv1.0" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "MaxProtocol = TLSv1.2" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "CipherString = DEFAULT@SECLEVEL=1" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& echo "" >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& cat /etc/ssl/openssl.cnf >> /etc/ssl/openssl.cnf.new \
|
||||||
|
&& mv /etc/ssl/openssl.cnf.new /etc/ssl/openssl.cnf
|
||||||
|
|
||||||
|
# Set environment variable to use the custom OpenSSL configuration
|
||||||
|
ENV OPENSSL_CONF=/etc/ssl/openssl.cnf
|
||||||
|
|
||||||
|
# Configure and install PHP extensions
|
||||||
|
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp
|
||||||
|
|
||||||
|
RUN docker-php-ext-install -j$(nproc) \
|
||||||
|
bcmath \
|
||||||
|
ctype \
|
||||||
|
fileinfo \
|
||||||
|
gd \
|
||||||
|
intl \
|
||||||
|
mbstring \
|
||||||
|
pdo \
|
||||||
|
pdo_mysql \
|
||||||
|
xml \
|
||||||
|
zip \
|
||||||
|
opcache \
|
||||||
|
pcntl \
|
||||||
|
sockets
|
||||||
|
|
||||||
|
# Install PECL extensions
|
||||||
|
RUN pecl install redis && docker-php-ext-enable redis
|
||||||
|
|
||||||
|
# Install SQL Server extensions
|
||||||
|
RUN pecl install sqlsrv && docker-php-ext-enable sqlsrv
|
||||||
|
RUN pecl install pdo_sqlsrv && docker-php-ext-enable pdo_sqlsrv
|
||||||
|
|
||||||
|
# Clean up PECL cache
|
||||||
|
RUN rm -rf /tmp/pear
|
||||||
|
|
||||||
|
# Install Composer
|
||||||
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Install Node.js and npm (using NodeSource repository for latest version)
|
||||||
|
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
|
||||||
|
&& apt-get install -y nodejs
|
||||||
|
|
||||||
|
# Configure PHP-FPM
|
||||||
|
RUN sed -i 's/listen = 127.0.0.1:9000/listen = 127.0.0.1:9000/' /usr/local/etc/php-fpm.d/www.conf
|
||||||
|
|
||||||
|
# Configure PHP settings
|
||||||
|
RUN echo "upload_max_filesize = 100M" >> /usr/local/etc/php/conf.d/uploads.ini \
|
||||||
|
&& echo "post_max_size = 100M" >> /usr/local/etc/php/conf.d/uploads.ini \
|
||||||
|
&& echo "max_execution_time = 300" >> /usr/local/etc/php/conf.d/uploads.ini \
|
||||||
|
&& echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/uploads.ini \
|
||||||
|
&& echo "opcache.enable=1" >> /usr/local/etc/php/conf.d/opcache.ini \
|
||||||
|
&& echo "opcache.memory_consumption=128" >> /usr/local/etc/php/conf.d/opcache.ini \
|
||||||
|
&& echo "opcache.interned_strings_buffer=8" >> /usr/local/etc/php/conf.d/opcache.ini \
|
||||||
|
&& echo "opcache.max_accelerated_files=4000" >> /usr/local/etc/php/conf.d/opcache.ini \
|
||||||
|
&& echo "opcache.revalidate_freq=2" >> /usr/local/etc/php/conf.d/opcache.ini \
|
||||||
|
&& echo "opcache.fast_shutdown=1" >> /usr/local/etc/php/conf.d/opcache.ini
|
||||||
|
|
||||||
|
# Remove default nginx configuration and configure Nginx
|
||||||
|
RUN rm -f /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
|
COPY <<EOF /etc/nginx/nginx.conf
|
||||||
|
user www-data;
|
||||||
|
worker_processes auto;
|
||||||
|
pid /run/nginx.pid;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
use epoll;
|
||||||
|
multi_accept on;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" '
|
||||||
|
'\$status \$body_bytes_sent "\$http_referer" '
|
||||||
|
'"\$http_user_agent" "\$http_x_forwarded_for"';
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log main;
|
||||||
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
types_hash_max_size 2048;
|
||||||
|
client_max_body_size 100M;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_types
|
||||||
|
text/plain
|
||||||
|
text/css
|
||||||
|
text/xml
|
||||||
|
text/javascript
|
||||||
|
application/json
|
||||||
|
application/javascript
|
||||||
|
application/xml+rss
|
||||||
|
application/atom+xml
|
||||||
|
image/svg+xml;
|
||||||
|
|
||||||
|
include /etc/nginx/conf.d/*.conf;
|
||||||
|
include /etc/nginx/sites-enabled/*;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Configure Laravel site
|
||||||
|
RUN mkdir -p /etc/nginx/sites-enabled
|
||||||
|
COPY <<EOF /etc/nginx/sites-enabled/default
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
root /var/www/html/public;
|
||||||
|
index index.php index.html index.htm;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files \$uri \$uri/ /index.php?\$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME \$realpath_root\$fastcgi_script_name;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_read_timeout 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
try_files \$uri =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Create required directories
|
||||||
|
RUN mkdir -p /var/run \
|
||||||
|
&& mkdir -p /var/log/supervisor
|
||||||
|
|
||||||
|
# Configure Supervisor
|
||||||
|
COPY <<EOF /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
[unix_http_server]
|
||||||
|
file=/var/run/supervisor.sock
|
||||||
|
chmod=0700
|
||||||
|
|
||||||
|
[supervisord]
|
||||||
|
nodaemon=true
|
||||||
|
logfile=/var/log/supervisor/supervisord.log
|
||||||
|
pidfile=/var/run/supervisord.pid
|
||||||
|
user=root
|
||||||
|
|
||||||
|
[rpcinterface:supervisor]
|
||||||
|
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||||
|
|
||||||
|
[supervisorctl]
|
||||||
|
serverurl=unix:///var/run/supervisor.sock
|
||||||
|
|
||||||
|
[program:nginx]
|
||||||
|
command=nginx -g "daemon off;"
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stderr_logfile=/var/log/supervisor/nginx.err.log
|
||||||
|
stdout_logfile=/var/log/supervisor/nginx.out.log
|
||||||
|
user=root
|
||||||
|
|
||||||
|
[program:php-fpm]
|
||||||
|
command=php-fpm -F
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
stderr_logfile=/var/log/supervisor/php-fpm.err.log
|
||||||
|
stdout_logfile=/var/log/supervisor/php-fpm.out.log
|
||||||
|
user=root
|
||||||
|
|
||||||
|
[program:laravel-worker]
|
||||||
|
process_name=%(program_name)s_%(process_num)02d
|
||||||
|
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3 --max-time=3600
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
user=www-data
|
||||||
|
numprocs=1
|
||||||
|
redirect_stderr=true
|
||||||
|
stdout_logfile=/var/log/supervisor/worker.log
|
||||||
|
stopwaitsecs=3600
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Create startup script
|
||||||
|
COPY <<EOF /usr/local/bin/start.sh
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Create directories if they don't exist
|
||||||
|
mkdir -p /var/www/html/storage/logs
|
||||||
|
mkdir -p /var/www/html/storage/framework/cache
|
||||||
|
mkdir -p /var/www/html/storage/framework/sessions
|
||||||
|
mkdir -p /var/www/html/storage/framework/views
|
||||||
|
mkdir -p /var/www/html/bootstrap/cache
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
chown -R www-data:www-data /var/www/html/storage || true
|
||||||
|
chown -R www-data:www-data /var/www/html/bootstrap/cache || true
|
||||||
|
chmod -R 775 /var/www/html/storage || true
|
||||||
|
chmod -R 775 /var/www/html/bootstrap/cache || true
|
||||||
|
|
||||||
|
# Check if we're in a Laravel project and if vendor exists
|
||||||
|
if [ -f "/var/www/html/artisan" ] && [ ! -d "/var/www/html/vendor" ]; then
|
||||||
|
echo "Installing Composer dependencies..."
|
||||||
|
composer install --no-dev --optimize-autoloader
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if package.json exists and node_modules doesn't
|
||||||
|
if [ -f "/var/www/html/package.json" ] && [ ! -d "/var/www/html/node_modules" ]; then
|
||||||
|
echo "Installing npm dependencies..."
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run Laravel optimizations if this is a Laravel project
|
||||||
|
if [ -f "/var/www/html/artisan" ]; then
|
||||||
|
echo "Running Laravel optimizations..."
|
||||||
|
php artisan config:cache || true
|
||||||
|
php artisan route:cache || true
|
||||||
|
php artisan view:cache || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start supervisor
|
||||||
|
exec supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||||
|
EOF
|
||||||
|
|
||||||
|
RUN chmod +x /usr/local/bin/start.sh
|
||||||
|
|
||||||
|
# Set correct ownership
|
||||||
|
RUN chown -R www-data:www-data /var/www/html
|
||||||
|
|
||||||
|
# Expose port
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# Start the application
|
||||||
|
CMD ["/usr/local/bin/start.sh"]
|
||||||
37
dockerfile-php-sql-2008/docker-compose.yml
Normal file
37
dockerfile-php-sql-2008/docker-compose.yml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
#build: .
|
||||||
|
# Or use your built image:
|
||||||
|
image: laravel-sqlserver-2008:latest
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
volumes:
|
||||||
|
- /Volumes/SSD_240/desarrollos/dev-laravel/example-test-components:/var/www/html # Mount your Laravel project directory
|
||||||
|
- /Volumes/HDD_MINI/docker-external-volumes/storage-laravel/example-test-components:/var/www/html/storage
|
||||||
|
environment:
|
||||||
|
- APP_ENV=production
|
||||||
|
- APP_DEBUG=false
|
||||||
|
- APP_KEY=base64:0v4AkqVDVv4/Ly5+qIMn/1fFWszx5wxp5arBV9llBmI=
|
||||||
|
- DB_CONNECTION=sqlsrv
|
||||||
|
- DB_HOST=192.168.1.112
|
||||||
|
- DB_PORT=1433
|
||||||
|
- DB_DATABASE=db_pruebas
|
||||||
|
- DB_USERNAME=sa
|
||||||
|
- DB_PASSWORD=1a2s3d4f5G
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
networks:
|
||||||
|
- laravel-network
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:7-alpine
|
||||||
|
ports:
|
||||||
|
- "6379:6379"
|
||||||
|
volumes:
|
||||||
|
- /Volumes/HDD_MINI/docker-external-volumes/storage-redis/example-test-components:/data
|
||||||
|
networks:
|
||||||
|
- laravel-network
|
||||||
|
|
||||||
|
networks:
|
||||||
|
laravel-network:
|
||||||
|
driver: bridge
|
||||||
77
dockerfile-php-sql-alternative/Dockerfile
Normal file
77
dockerfile-php-sql-alternative/Dockerfile
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# Dockerfile for a generic Laravel 10 environment
|
||||||
|
# with SQL Server 2008 Support (via FreeTDS)
|
||||||
|
|
||||||
|
# Use PHP 8.2 as a base image, required for Laravel 10
|
||||||
|
ARG PHP_VERSION=8.3.20
|
||||||
|
FROM php:${PHP_VERSION}-fpm
|
||||||
|
|
||||||
|
# Set arguments for user and group IDs. These can be passed during build time.
|
||||||
|
ARG LARAVEL_SAIL_USER_ID=1000
|
||||||
|
ARG LARAVEL_SAIL_GROUP_ID=1000
|
||||||
|
|
||||||
|
# Set Working Directory for the container
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Set environment variables to prevent interactive prompts during installation
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
ENV TZ=UTC
|
||||||
|
|
||||||
|
# 1. Install System Dependencies
|
||||||
|
# - Common tools: git, curl, zip, etc.
|
||||||
|
# - PHP extension dependencies: libpng, libxml, etc.
|
||||||
|
# - FreeTDS: The key component for connecting to SQL Server 2008 (freetds-dev, freetds-bin)
|
||||||
|
# - Node.js and npm: For running `npm run dev`
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
zip \
|
||||||
|
unzip \
|
||||||
|
libpng-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
libzip-dev \
|
||||||
|
libonig-dev \
|
||||||
|
gnupg \
|
||||||
|
ca-certificates \
|
||||||
|
# Install FreeTDS libraries
|
||||||
|
freetds-dev \
|
||||||
|
freetds-bin \
|
||||||
|
tdsodbc && \
|
||||||
|
# Install Node.js (we'll use v18)
|
||||||
|
mkdir -p /etc/apt/keyrings && \
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
|
||||||
|
NODE_MAJOR=18 && \
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y nodejs && \
|
||||||
|
# Clean up apt cache
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# 2. Install PHP Extensions
|
||||||
|
# - We install common Laravel extensions.
|
||||||
|
# - We configure and install pdo_dblib, which uses FreeTDS to connect to SQL Server.
|
||||||
|
RUN docker-php-ext-configure pdo_dblib --with-libdir=/usr/lib/x86_64-linux-gnu && \
|
||||||
|
docker-php-ext-install \
|
||||||
|
pdo \
|
||||||
|
pdo_dblib \
|
||||||
|
bcmath \
|
||||||
|
gd \
|
||||||
|
exif \
|
||||||
|
pcntl \
|
||||||
|
zip \
|
||||||
|
mbstring
|
||||||
|
|
||||||
|
# 3. Install Composer (PHP Package Manager)
|
||||||
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# 4. Create a non-root user to run the application
|
||||||
|
# This is a security best practice and helps avoid permission errors.
|
||||||
|
RUN groupadd --force -g $LARAVEL_SAIL_GROUP_ID sail && \
|
||||||
|
useradd -ms /bin/bash --no-user-group -g sail -u $LARAVEL_SAIL_USER_ID sail
|
||||||
|
|
||||||
|
# 5. Switch to the non-root user
|
||||||
|
USER sail
|
||||||
|
|
||||||
|
# The image build process stops here. The working directory is set to /var/www/html.
|
||||||
|
# When you use this image, you will mount your project code into this directory.
|
||||||
17
dockerfile-php-sql-alternative/entrypoint.sh
Executable file
17
dockerfile-php-sql-alternative/entrypoint.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# /my-new-laravel-app/entrypoint.sh
|
||||||
|
|
||||||
|
# Install/update dependencies every time the container starts
|
||||||
|
echo "Running composer install..."
|
||||||
|
composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
|
echo "Running npm install..."
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# Run the Vite development server in the background
|
||||||
|
echo "Starting Vite dev server (npm run dev)..."
|
||||||
|
npm run dev &
|
||||||
|
|
||||||
|
# Start the Laravel development server in the foreground
|
||||||
|
echo "Starting Laravel dev server (php artisan serve)..."
|
||||||
|
php artisan serve --host=0.0.0.0 --port=8000
|
||||||
83
dockerfile-php-sql-original/Dockerfile
Normal file
83
dockerfile-php-sql-original/Dockerfile
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# Dockerfile for a generic Laravel 10 environment
|
||||||
|
# with Official Microsoft SQL Server Drivers (sqlsrv, pdo_sqlsrv)
|
||||||
|
|
||||||
|
# Use PHP 8.2 as a base image, required for Laravel 10
|
||||||
|
ARG PHP_VERSION=8.3.20
|
||||||
|
FROM php:${PHP_VERSION}-fpm
|
||||||
|
|
||||||
|
# Set arguments for user and group IDs. These can be passed during build time.
|
||||||
|
ARG LARAVEL_SAIL_USER_ID=1000
|
||||||
|
ARG LARAVEL_SAIL_GROUP_ID=1000
|
||||||
|
|
||||||
|
# Set Working Directory for the container
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Set environment variables to prevent interactive prompts during installation
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
ENV TZ=UTC
|
||||||
|
# Accept the EULA for the Microsoft ODBC driver
|
||||||
|
ENV ACCEPT_EULA=Y
|
||||||
|
|
||||||
|
# 1. Install System Dependencies
|
||||||
|
# This section installs the official Microsoft ODBC Driver 17 for SQL Server.
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y \
|
||||||
|
# Common tools
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
zip \
|
||||||
|
unzip \
|
||||||
|
gnupg \
|
||||||
|
ca-certificates \
|
||||||
|
apt-transport-https \
|
||||||
|
# Dependencies for PECL and PHP extensions
|
||||||
|
libpng-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
libzip-dev \
|
||||||
|
libonig-dev \
|
||||||
|
build-essential \
|
||||||
|
unixodbc-dev && \
|
||||||
|
# Add Microsoft's official repository for Debian 12 (Bookworm)
|
||||||
|
# This is the corrected method to handle the GPG key securely.
|
||||||
|
mkdir -p /etc/apt/keyrings && \
|
||||||
|
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /etc/apt/keyrings/microsoft.gpg && \
|
||||||
|
chmod 644 /etc/apt/keyrings/microsoft.gpg && \
|
||||||
|
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/debian/12/prod bookworm main" | tee /etc/apt/sources.list.d/mssql-release.list && \
|
||||||
|
apt-get update && \
|
||||||
|
# Install the ODBC driver
|
||||||
|
apt-get install -y msodbcsql17 && \
|
||||||
|
# Install Node.js (we'll use v18)
|
||||||
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
|
||||||
|
NODE_MAJOR=18 && \
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-get install -y nodejs && \
|
||||||
|
# Clean up apt cache
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# 2. Install PHP Extensions
|
||||||
|
# This section installs the sqlsrv and pdo_sqlsrv extensions via PECL.
|
||||||
|
RUN pecl install sqlsrv pdo_sqlsrv && \
|
||||||
|
docker-php-ext-enable sqlsrv pdo_sqlsrv && \
|
||||||
|
docker-php-ext-install \
|
||||||
|
bcmath \
|
||||||
|
gd \
|
||||||
|
exif \
|
||||||
|
pcntl \
|
||||||
|
zip \
|
||||||
|
mbstring
|
||||||
|
|
||||||
|
# 3. Install Composer (PHP Package Manager)
|
||||||
|
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# 4. Create a non-root user to run the application
|
||||||
|
# This is a security best practice and helps avoid permission errors.
|
||||||
|
RUN groupadd --force -g $LARAVEL_SAIL_GROUP_ID sail && \
|
||||||
|
useradd -ms /bin/bash --no-user-group -g sail -u $LARAVEL_SAIL_USER_ID sail
|
||||||
|
|
||||||
|
# 5. Switch to the non-root user
|
||||||
|
USER sail
|
||||||
|
|
||||||
|
# The image build process stops here. The working directory is set to /var/www/html.
|
||||||
|
# When you use this image, you will mount your project code into this directory.
|
||||||
25
dockerfile-php-sql-original/entrypoint.sh
Normal file
25
dockerfile-php-sql-original/entrypoint.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# entrypoint.sh
|
||||||
|
|
||||||
|
# This script is executed when the container starts.
|
||||||
|
# It runs both the PHP artisan server and the Node.js Vite server.
|
||||||
|
|
||||||
|
echo "Starting development servers..."
|
||||||
|
|
||||||
|
# Run NPM install just in case new packages were added
|
||||||
|
echo "Running npm install..."
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# Run composer install just in case
|
||||||
|
echo "Running composer install..."
|
||||||
|
composer install
|
||||||
|
|
||||||
|
# Run the Vite development server in the background
|
||||||
|
# The '&' symbol sends the process to the background
|
||||||
|
echo "Starting Vite dev server (npm run dev)..."
|
||||||
|
npm run dev &
|
||||||
|
|
||||||
|
# Start the Laravel development server in the foreground
|
||||||
|
# The --host=0.0.0.0 is crucial to make it accessible from outside the container
|
||||||
|
echo "Starting Laravel dev server (php artisan serve)..."
|
||||||
|
php artisan serve --host=0.0.0.0 --port=8000
|
||||||
Reference in New Issue
Block a user