Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 26 additions & 0 deletions Dockerfile.bench
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM ubuntu:24.04

# Install Apache Bench and other testing tools
RUN apt-get update && apt-get install -y \
apache2-utils \
curl \
bc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Create results directory
RUN mkdir -p /results

# Copy test scripts
COPY test-nginx-performance.sh /test-nginx-performance.sh
COPY analyze-php-fpm-config.sh /analyze-php-fpm-config.sh
COPY analyze-nginx-config.sh /analyze-nginx-config.sh

RUN chmod +x /test-nginx-performance.sh \
/analyze-php-fpm-config.sh \
/analyze-nginx-config.sh

WORKDIR /

# Default command runs performance tests
CMD ["/test-nginx-performance.sh"]
82 changes: 82 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Test environment Dockerfile
FROM ubuntu:24.04

# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies
RUN apt-get update && apt-get install -y \
php8.3 \
php8.3-cli \
php8.3-curl \
php8.3-gd \
php8.3-intl \
php8.3-mbstring \
php8.3-mysql \
php8.3-xml \
php8.3-zip \
php8.3-bcmath \
php8.3-memcache \
mysql-client \
git \
unzip \
curl \
ca-certificates \
gnupg \
lsb-release \
&& rm -rf /var/lib/apt/lists/*

# Install Docker CLI for container inspection tests
RUN install -m 0755 -d /etc/apt/keyrings \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
&& chmod a+r /etc/apt/keyrings/docker.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null \
&& apt-get update \
&& apt-get install -y docker-ce-cli \
&& rm -rf /var/lib/apt/lists/*

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Set working directory
WORKDIR /app

# Copy application files
COPY yiimp2 /app/yiimp2
COPY sql /app/sql
COPY bin /app/bin
COPY config /app/config
COPY web /app/web
COPY stratum /app/stratum
COPY docker-compose.yml /app/docker-compose.yml
COPY docker-compose.test.yml /app/docker-compose.test.yml
COPY run-tests.sh /app/run-tests.sh
RUN chmod +x /app/run-tests.sh

# Install PHP dependencies
WORKDIR /app/yiimp2
RUN composer install --no-interaction --prefer-dist --optimize-autoloader

# Create necessary directories
RUN mkdir -p /app/test-results \
&& mkdir -p /app/yiimp2/runtime \
&& mkdir -p /app/yiimp2/web/assets \
&& mkdir -p /app/yiimp2/tests/_output \
&& chmod -R 777 /app/yiimp2/runtime \
&& chmod -R 777 /app/yiimp2/web/assets \
&& chmod -R 777 /app/yiimp2/tests/_output \
&& chmod -R 777 /app/test-results

# Create test configuration
RUN echo '<?php\n\
return [\n\
"class" => "yii\\db\\Connection",\n\
"dsn" => "mysql:host=" . getenv("DB_HOST") . ";dbname=" . getenv("DB_NAME"),\n\
"username" => getenv("DB_USER"),\n\
"password" => getenv("DB_PASSWORD"),\n\
"charset" => "utf8",\n\
];' > /app/yiimp2/config/db-test.php

# Set entrypoint
ENTRYPOINT ["/app/run-tests.sh"]
CMD ["all"]
37 changes: 20 additions & 17 deletions Dockerfile.yiimp
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ COPY --from=docker.io/library/composer:latest /usr/bin/composer /usr/bin/compose
RUN set -xe \
&& : "---------- Modify apache config ----------" \
&& a2enmod remoteip \
&& a2enmod rewrite
&& a2enmod rewrite \
&& a2enmod ssl

COPY config/000-default.conf /etc/apache2/sites-available/
COPY config/ports.conf /etc/apache2/
RUN echo "RemoteIPHeader x-forwarded-for" >> /etc/apache2/apache2.conf \
&& echo "RemoteIPInternalProxy 127.0.0.1" >> /etc/apache2/apache2.conf

# enable yii2-port on alternate vhost
COPY config/001-yiimp2.conf /etc/apache2/sites-available/
RUN a2ensite 001-yiimp2

# add php-mcrypt from pecl
RUN pecl install mcrypt
RUN echo "extension=mcrypt.so" >> /etc/php/8.1/apache2/php.ini && \
Expand All @@ -51,18 +48,19 @@ RUN python3 -m venv /opt/certbot/ && \
/opt/certbot/bin/pip install certbot && \
ln -s /opt/certbot/bin/certbot /usr/bin/certbot

COPY --chmod=755 /bin/letsencrypt-* /usr/local/bin/
COPY --chmod=755 bin/letsencrypt-* /usr/local/bin/

# build stratum binary
COPY /stratum /tmp/stratum
COPY stratum /tmp/stratum
WORKDIR /tmp/stratum
RUN make buildonly && cp stratum /usr/bin/
RUN cp algos/blake3/blake3.h algos/xelisv2-pepew/blake3.h && \
make buildonly && cp stratum /usr/bin/

# create default log directory
RUN mkdir /var/log/yiimp

# Build devel image
FROM baseimage as image-devel
FROM baseimage AS image-devel

RUN set -xe \
&& : "---------- changes only on devel env e.g. enable xdebug ----------"
Expand All @@ -74,7 +72,7 @@ RUN set -xe \
&& : "---------- Install Xdebug from apt repo ----------" \
&& apt-get install -y php-xdebug

COPY /config/xdebug.ini /usr/local/etc/php/conf.d/
COPY config/xdebug.ini /usr/local/etc/php/conf.d/

# change apache run-group to match with virtualbox-env
RUN sed -i 's/APACHE_RUN_GROUP:=www-data/APACHE_RUN_GROUP:=vboxsf/g' /etc/apache2/envvars
Expand All @@ -84,15 +82,20 @@ WORKDIR /var/www/
CMD ["apache2-foreground"]

# Build production image
FROM baseimage as image-prod
FROM baseimage AS image-prod

COPY --chown=www-data:www-data /web/ /var/www/
COPY --chown=www-data:www-data /yiimp2/ /var/yiimp2/
COPY --chown=www-data:www-data web/ /var/www/

WORKDIR /var/yiimp2/
RUN sudo -u www-data composer install
# Create runtime and log directories for Yii1 application
RUN mkdir -p /var/www/yaamp/runtime && \
mkdir -p /var/log/apache2 && \
mkdir -p /var/log/yiimp && \
chown -R www-data:www-data /var/www/yaamp/runtime && \
chown -R www-data:www-data /var/log/yiimp && \
chmod -R 775 /var/www/yaamp/runtime && \
chmod -R 775 /var/log/yiimp

WORKDIR /var/www/

COPY /config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["/usr/bin/supervisord"]
COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["/usr/bin/supervisord"]
75 changes: 75 additions & 0 deletions Dockerfile.yiimp2
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
FROM ubuntu:24.04 AS baseimage

ENV DEBIAN_FRONTEND=noninteractive

RUN set -xe \
&& : "---------- Fix possible vulnerabilities ----------" \
&& apt-get update && apt-get dist-upgrade -y \
&& : "---------- add tools ----------" \
&& apt-get install -y git bc dumb-init supervisor cron logrotate vim less nano mc memcached apache2 libapache2-mod-php sudo \
&& : "---------- Persistent dependencies ----------" \
&& apt-get install -y libgd-dev libicu-dev libmariadb-dev-compat libxml2-dev libonig-dev libcurl4-openssl-dev libssl-dev libxslt1-dev libzip-dev libz-dev libmemcached-dev \
&& : "---------- php extensions ----------" \
&& apt-get install -y php-dev php-bcmath php-curl php-exif php-gd php-intl php-memcache php-memcached php-opcache php-mbstring php-mysqli php-soap php-shmop php-sysvshm php-sysvsem php-sysvmsg php-xml php-xsl php-zip \
&& apt-get clean

RUN set -xe \
&& : "---------- Copy latest composer ----------"
COPY --from=docker.io/library/composer:latest /usr/bin/composer /usr/bin/composer

RUN set -xe \
&& : "---------- Modify apache config ----------" \
&& a2enmod remoteip \
&& a2enmod rewrite \
&& a2enmod ssl

# Configure Apache with yiimp2-specific ports and vhost
COPY config/ports.conf.yiimp2 /etc/apache2/ports.conf
COPY config/001-yiimp2.conf /etc/apache2/sites-available/
RUN a2ensite 001-yiimp2 && a2dissite 000-default

RUN echo "RemoteIPHeader x-forwarded-for" >> /etc/apache2/apache2.conf \
&& echo "RemoteIPInternalProxy 127.0.0.1" >> /etc/apache2/apache2.conf

# create default log directory
RUN mkdir -p /var/log/yiimp

# Build devel image
FROM baseimage AS image-devel

RUN set -xe \
&& : "---------- changes only on devel env e.g. enable xdebug ----------"

# Install Xdebug from apt repo
RUN set -xe \
&& : "---------- Install Xdebug from apt repo ----------" \
&& apt-get install -y php-xdebug

COPY config/xdebug.ini /usr/local/etc/php/conf.d/

# Copy yiimp2 application for development
COPY --chown=www-data:www-data yiimp2/ /var/yiimp2/

# Install Composer dependencies (including dev dependencies)
WORKDIR /var/yiimp2/
RUN sudo -u www-data composer install

WORKDIR /var/yiimp2/
CMD ["apache2-foreground"]

# Build production image
FROM baseimage AS image-prod

# Copy yiimp2 application
COPY --chown=www-data:www-data yiimp2/ /var/yiimp2/

# Install Composer dependencies
WORKDIR /var/yiimp2/
RUN sudo -u www-data composer install --no-dev --optimize-autoloader

# Configure supervisor with yiimp2-specific configuration
COPY config/supervisord.conf.yiimp2 /etc/supervisor/conf.d/supervisord.conf

WORKDIR /var/yiimp2/

CMD ["/usr/bin/supervisord"]
64 changes: 64 additions & 0 deletions Dockerfile.yiimp2-backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Dockerfile for Yiimp2 Backend Scripts
# Requirements: 20.3, 20.6, 20.7, 20.8

FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

# Install PHP CLI and dependencies for backend scripts
RUN apt-get update && apt-get install -y \
php8.3-cli \
php8.3-bcmath \
php8.3-curl \
php8.3-gd \
php8.3-intl \
php8.3-mbstring \
php8.3-mysql \
php8.3-opcache \
php8.3-xml \
php8.3-zip \
php8.3-memcache \
bc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Copy Yii1 framework (required by backend scripts)
COPY web/framework /var/www/framework

# Copy backend scripts from web/yaamp
COPY web/yaamp /var/www/yaamp

# Copy yiimp2-specific backend scripts and runconsole
COPY web/main-yiimp2.sh /var/www/yaamp/main-yiimp2.sh
COPY web/loop2-yiimp2.sh /var/www/yaamp/loop2-yiimp2.sh
COPY web/blocks-yiimp2.sh /var/www/yaamp/blocks-yiimp2.sh
COPY web/runconsole-yiimp2.php /var/www/yaamp/runconsole-yiimp2.php

# Create symlinks for Yii1 autoloader (class db_coins -> db_coinsModel.php)
# Yii1 expects filename to match class name, but files have "Model" suffix
RUN cd /var/www/yaamp/models && \
for file in *Model.php; do \
if [ -f "$file" ]; then \
base=$(basename "$file" Model.php); \
ln -sf "$file" "${base}.php"; \
fi; \
done

# Make scripts executable
RUN chmod +x /var/www/yaamp/main-yiimp2.sh \
&& chmod +x /var/www/yaamp/loop2-yiimp2.sh \
&& chmod +x /var/www/yaamp/blocks-yiimp2.sh

# Create runtime and log directories
RUN mkdir -p /var/www/yaamp/runtime \
&& mkdir -p /var/log/yiimp2 \
&& chown -R www-data:www-data /var/www/yaamp/runtime \
&& chown -R www-data:www-data /var/log/yiimp2 \
&& chmod -R 775 /var/www/yaamp/runtime \
&& chmod -R 775 /var/log/yiimp2

WORKDIR /var/www/yaamp

# Set CMD to run specified backend script
# This will be overridden in docker-compose.yml for each service
CMD ["/bin/bash"]
Loading