1- FROM php:8.2-apache
1+ # Unified Docker Image for AI MultiBarcode Capture
2+ # Contains Apache+PHP, MySQL, and phpMyAdmin in a single container
23
3- # Install system dependencies
4+ FROM ubuntu:22.04
5+
6+ # Prevent interactive prompts during package installation
7+ ENV DEBIAN_FRONTEND=noninteractive
8+
9+ # Install all required packages
410RUN apt-get update && apt-get install -y \
5- git \
11+ apache2 \
12+ php8.1 \
13+ php8.1-mysql \
14+ libapache2-mod-php8.1 \
15+ php8.1-curl \
16+ php8.1-cli \
17+ php8.1-mbstring \
18+ php8.1-xml \
19+ php8.1-zip \
20+ mysql-server \
21+ mysql-client \
22+ wget \
623 curl \
7- libpng-dev \
8- libonig-dev \
9- libxml2-dev \
10- zip \
11- unzip \
24+ supervisor \
25+ nano \
1226 && rm -rf /var/lib/apt/lists/*
1327
14- # Install PHP extensions
15- RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
16-
17- # Enable Apache modules
18- RUN a2enmod rewrite headers expires ssl
28+ # Install phpMyAdmin
29+ RUN wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.tar.gz \
30+ && tar xzf phpMyAdmin-5.2.1-all-languages.tar.gz \
31+ && mv phpMyAdmin-5.2.1-all-languages /var/www/html/phpmyadmin \
32+ && rm phpMyAdmin-5.2.1-all-languages.tar.gz
1933
20- # Copy custom Apache configuration
34+ # Configure Apache
35+ RUN a2enmod rewrite headers expires env
2136COPY apache/000-default.conf /etc/apache2/sites-available/000-default.conf
22- COPY apache/ssl-default.conf /etc/apache2/sites-available/ssl-default.conf
2337
24- # Generate SSL certificates inside container
25- RUN mkdir -p /etc/ssl/certs /etc/ssl/private && \
26- openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
27- -keyout /etc/ssl/private/wms.key \
28- -out /etc/ssl/certs/wms.crt \
29- -subj "/C=US/ST=State/L=City/O=WMS/CN=wms.local" \
30- -addext "subjectAltName=DNS:localhost,DNS:wms.local,IP:127.0.0.1,IP:192.168.1.188" && \
31- chmod 600 /etc/ssl/private/wms.key && \
32- chmod 644 /etc/ssl/certs/wms.crt
38+ # Configure phpMyAdmin
39+ COPY phpmyadmin/config.inc.php /var/www/html/phpmyadmin/config.inc.php
3340
34- # Enable SSL site
35- RUN a2ensite ssl-default
41+ # Configure MySQL
42+ COPY mysql/my.cnf /etc/mysql/conf.d/custom.cnf
3643
37- # Set working directory
38- WORKDIR /var/www/html
39-
40- # Copy application source
44+ # Copy application source code
4145COPY src/ /var/www/html/
4246
43- # Set proper permissions
44- RUN chown -R www-data:www-data /var/www/html \
47+ # Copy database initialization script
48+ COPY database/init.sql /tmp/init.sql
49+
50+ # Create necessary directories first
51+ RUN mkdir -p /scripts
52+
53+ # Copy startup script and fix line endings
54+ COPY startup.sh /startup.sh
55+ RUN sed -i 's/\r $//' /startup.sh && chmod +x /startup.sh
56+
57+ # Create necessary directories and set permissions
58+ RUN mkdir -p /var/run/mysqld \
59+ && mkdir -p /var/log/supervisor \
60+ && mkdir -p /var/log/mysql \
61+ && mkdir -p /var/log/apache2 \
62+ && mkdir -p /scripts \
63+ && chown mysql:mysql /var/run/mysqld \
64+ && chown mysql:mysql /var/lib/mysql \
65+ && chown -R www-data:www-data /var/www/html \
4566 && chmod -R 755 /var/www/html
4667
47- # Expose port 80
48- EXPOSE 80
68+ # Initialize MySQL data directory (if not already done)
69+ RUN service mysql start && sleep 5 && service mysql stop || true
70+
71+ # Environment variables with defaults
72+ ENV MYSQL_ROOT_PASSWORD=
73+ ENV MYSQL_DATABASE=barcode_wms
74+ ENV MYSQL_USER=wms_user
75+ ENV MYSQL_PASSWORD=wms_password
76+
77+ # Expose ports (will be dynamic based on WEB_PORT)
78+ EXPOSE 3500
4979
50- CMD ["apache2-foreground" ]
80+ # Start the services
81+ CMD ["/startup.sh" ]
0 commit comments