diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..be6c4d678 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,74 @@ +### GitHub ### +.git +.github + +### IDE ### +.idea + +### TorrentPier ### +*.log +*.integrity +.env +.php_cs.cache +#-- data folder +##-> avatats +data/avatars +!data/avatars/gallery/bot.gif +!data/avatars/gallery/noavatar.png +##-> uploads +data/uploads +!data/uploads/.htaccess +!data/uploads/thumbs/.keep +#-- internal_data folder +##-> atom +internal_data/atom +!internal_data/atom/.keep +##-> cache +internal_data/cache +!internal_data/cache/.htaccess +##-> log +internal_data/log +!internal_data/log/.htaccess +##-> triggers +internal_data/triggers +!internal_data/triggers/.htaccess +!internal_data/triggers/$on +##-> updater.json +internal_data/updater.json +#-- sitemap +sitemap +!sitemap/.keep +#-- other +library/config.local.php +vendor + +### Archives ### +*.phar +*.rar +*.tar +*.gz +*.zip +*.7z +*.torrent +*.pak + +### Windows ### +Thumbs.db +Desktop.ini +$RECYCLE.BIN/ +*.lnk +*.bat + +### OSX ### +.DS_Store +.AppleDouble +.LSOverride +._* +.Spotlight-V100 +.Trashes +*.orig +*.rej + +### Docker ### +docker-compose.override.yml +docker-compose.yml diff --git a/.gitignore b/.gitignore index dd0e1f365..231742590 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ $RECYCLE.BIN/ .Trashes *.orig *.rej + +### Docker ### +docker-compose.override.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..9134a1cb0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,72 @@ +FROM php:8.1-apache +LABEL maintainer="TorrentPier " + +# Enable Apache mod_rewrite +RUN a2enmod rewrite + +# Install GD2 +RUN apt-get update && apt-get install -y --no-install-recommends --allow-downgrades \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libonig-dev \ + libz-dev \ + zlib1g-dev \ + libpng-dev && \ + docker-php-ext-configure gd --with-freetype --with-jpeg && \ + docker-php-ext-install -j$(nproc) gd && \ + rm -rf /var/lib/apt/lists/* + +# Install mysqli +RUN docker-php-ext-install mysqli + +# Install mbstring +RUN docker-php-ext-install mbstring + +# Install bcmath +RUN docker-php-ext-install bcmath + +# Install zip & unzip +RUN apt-get update && apt-get install -y \ + libzip-dev \ + unzip && \ + docker-php-ext-install zip && \ + rm -rf /var/lib/apt/lists/* + +# Install intl +RUN apt-get update && apt-get install -y --no-install-recommends \ + g++ \ + libicu-dev \ + zlib1g-dev && \ + docker-php-ext-configure intl && \ + docker-php-ext-install intl && \ + rm -rf /var/lib/apt/lists/* + +# Custom php.ini settings +COPY docker/php/php.ini ${PHP_INI_DIR}/php.ini + +# Install composer +RUN curl -sS https://getcomposer.org/installer | \ + php -- --install-dir=/usr/bin/ --filename=composer + +# Set the work directory to /var/www/html so all subsequent commands in this file start from that directory. +# Also set this work directory so that it uses this directory everytime we use docker exec. +WORKDIR /var/www/html + +# Install the composer dependencies (no autoloader yet as that invalidates the docker cache) +COPY composer.json ./ +COPY composer.lock ./ +RUN composer install --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress && \ + composer clear-cache + +# Bundle source code into container. Important here is that copying is done based on the rules defined in the .dockerignore file. +COPY . /var/www/html + +# Dump the autoloader +RUN composer dump-autoload --optimize --classmap-authoritative --no-dev + +# Give apache write access to host +RUN chown -R www-data:www-data /var/www/html + +# This specifies on which port the application will run. This is pure communicative and makes this 12 factor app compliant +# (see https://12factor.net/port-binding). +EXPOSE 80 443 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..f3a3a47ce --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3.8' + +services: + torrentpier: + build: . + container_name: torrentpier + ports: + - "80:80" + - "443:443" + depends_on: + - db + db: + image: mariadb:latest + container_name: mariadb + restart: always + ports: + - "3306:3306" + environment: + MYSQL_ROOT_PASSWORD: super_password + MYSQL_DATABASE: database + MYSQL_USER: username + MYSQL_PASSWORD: password diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/docker/nginx/nginx.conf @@ -0,0 +1 @@ + diff --git a/docker/php/php.ini b/docker/php/php.ini new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/docker/php/php.ini @@ -0,0 +1 @@ +