Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a prod Dockerfile #1672

Merged
merged 19 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
46bbfd4
Add a "yes" option to skip confirmation prompts in install
PyRowMan Dec 17, 2024
f01238f
Fix artisna optimize by adding an application logo blade component
PyRowMan Dec 17, 2024
0cc0133
Add Docker setup with Dockerfile, docker-compose, and entrypoint
PyRowMan Dec 17, 2024
5a7ab28
Refactor Docker setup to clean up dependencies and configs
Dec 18, 2024
8c1a6f4
Merge branch 'master' into dockerfilev2
Dec 18, 2024
96b95dc
Add `.env.dist`, Manticore service, and environment substitution
Dec 18, 2024
0142267
Add Manticore service to docker-compose.yml
Dec 18, 2024
cbf63ac
Refactor .env file creation in docker entrypoint
Dec 19, 2024
93d64ef
Fix spacing issue in `docker-compose.yml` command block
Dec 19, 2024
0037ab6
Add Elasticsearch index creation and population to entrypoint
Dec 19, 2024
4b48429
Add conditional cache logic, folder creation, and PHP extensions
Dec 20, 2024
acb5b29
Update Docker image references and improve install script setup
Dec 20, 2024
546027a
Update .gitignore to include .php-cs-fixer.cache
Dec 20, 2024
6530cb3
Merge remote-tracking branch 'origin/master' into dockerfilev2
Dec 20, 2024
b0c5634
Moving environment variables into .env.dist and .env.example
Dec 20, 2024
b084d47
Moving environment variables into .env.dist and .env.example
Dec 20, 2024
513a1ff
Add custom PHP configuration to Dockerfile
Dec 20, 2024
fc060fd
Refactor paths and add support for Manticore initialization
Dec 20, 2024
abf8bc2
Merge branch 'master' into dockerfilev2
DariusIII Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ vendor/
docker/mariadb-data
docker/redis-data
docker/manticore-data
storage
resources
PyRowMan marked this conversation as resolved.
Show resolved Hide resolved
.env
73 changes: 73 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

FROM composer:latest AS composer-base
#FROM php:8.3-fpm AS php-base
FROM dunglas/frankenphp:1-php8.3
LABEL maintainer="Fossil01"
PyRowMan marked this conversation as resolved.
Show resolved Hide resolved
ENV SERVER_NAME=:80
ARG MYSQL_CLIENT="mariadb-client"
ARG SEVENZIP_VERSION=2407

WORKDIR /app


COPY --from=node:21 /usr/local/ /usr/local/
COPY --from=composer-base --link /usr/bin/composer /usr/bin/composer

RUN apt update \
&& apt install -y --no-install-recommends \
unrar-free 7zip lame libcap2-bin python3 \
curl zip unzip git nano bash-completion sudo wget tmux time fonts-powerline \
gnupg sqlite3 libpng-dev dnsutils jq htop iputils-ping net-tools ffmpeg \
jpegoptim webp optipng pngquant libavif-bin watch iproute2 nmon \
libonig-dev libxml2-dev libicu-dev libjpeg-dev libfreetype6-dev libxslt-dev $MYSQL_CLIENT libcurl4-openssl-dev \
&& wget https://mediaarea.net/repo/deb/repo-mediaarea_1.0-24_all.deb \
&& dpkg -i repo-mediaarea_1.0-24_all.deb \
&& apt update \
&& apt install -y libmediainfo0v5 mediainfo libzen0v5 \
&& docker-php-ext-install \
bcmath \
exif \
gd \
intl \
pdo_mysql \
sockets \
pcntl \
&& pecl install redis \
&& docker-php-ext-enable redis \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Determine ARCH and download and extract the appropriate version of 7-Zip
RUN ARCH="$(dpkg --print-architecture)" && \
if [ "$ARCH" = "amd64" ]; then \
SZIP_URL="https://www.7-zip.org/a/7z$SEVENZIP_VERSION-linux-x64.tar.xz"; \
fi && \
if [ "$ARCH" = "arm64" ]; then \
SZIP_URL="https://www.7-zip.org/a/7z$SEVENZIP_VERSION-linux-arm64.tar.xz"; \
fi && \
wget "$SZIP_URL" -O /tmp/7z.tar.xz && \
tar -xf /tmp/7z.tar.xz -C /tmp/ && \
mv /tmp/7zz /usr/bin/7zz && \
rm -f /tmp/7z.tar.xz && rm -f /tmp/7zzs

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN npm install -g bun pnpm

COPY --chmod=755 ./docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint

COPY . /app

RUN composer install

RUN chmod -R 755 /app/vendor/
RUN chmod -R 777 /app/storage/
RUN chmod -R 777 /app/resources/
RUN chmod -R 777 /app/public/

EXPOSE 80

CMD ["--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
ENTRYPOINT ["docker-entrypoint"]


85 changes: 42 additions & 43 deletions app/Console/Commands/InstallNntmux.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Process;
use Illuminate\Support\Str;

class InstallNntmux extends Command
{
Expand All @@ -15,7 +14,7 @@ class InstallNntmux extends Command
*
* @var string
*/
protected $signature = 'nntmux:install';
protected $signature = 'nntmux:install {--y|yes : Skip confirmation prompts and proceed with installation}';

/**
* The console command description.
Expand All @@ -36,45 +35,53 @@ public function __construct()

public function handle(): void
{
$error = false;

if ($this->confirm('Are you sure you want to install NNTmux? This will wipe your database!!')) {
if (File::exists(base_path().'/_install/install.lock')) {
if ($this->confirm('Do you want to remove install.lock file so you can continue with install?')) {
$this->info('Removing install.lock file so we can continue with install process');
$yesMode = $this->option('yes');
if (File::exists(base_path().'/_install/install.lock')) {
if ($yesMode) {
$this->info('Install is locked. The file "install.lock" is present. Use interactive mode to remove it.');
exit;
} else {
if ($this->confirm('Install is locked. Do you want to remove the "install.lock" file to continue?')) {
$this->info('Removing install.lock file so we can continue with install process...');
$remove = Process::timeout(600)->run('rm _install/install.lock');
echo $remove->output();
echo $remove->errorOutput();
} else {
$this->info('Not removing install.lock, stopping install process');
$this->info('Installation aborted. The file "install.lock" was not removed.');
exit;
}
}
$this->info('Migrating tables and seeding them with initial data');
if (config('app.env') !== 'production') {
$this->call('migrate:fresh', ['--seed' => true]);
} else {
$this->call('migrate:fresh', ['--force' => true, '--seed' => true]);
}

$paths = $this->updatePaths();
if ($paths !== false) {
$this->info('Paths checked successfully');
}
}

if (! $error && $this->addAdminUser()) {
File::put(base_path().'/_install/install.lock', 'application install locked on '.now());
$this->info('Generating application key');
$this->call('key:generate', ['--force' => true]);
$this->info('NNTmux installation completed successfully');
exit();
if (! $yesMode) {
if (! $this->confirm('Are you sure you want to install NNTmux? This will wipe your database!!')) {
$this->info('Installation aborted by user.');
exit;
}
}

$this->error('NNTmux installation failed. Fix reported problems and try again');
$this->info('Migrating tables and seeding them with initial data');
if (config('app.env') !== 'production') {
$this->call('migrate:fresh', ['--seed' => true]);
} else {
$this->info('Stopping install process');
exit;
$this->call('migrate:fresh', ['--force' => true, '--seed' => true]);
}

$paths = $this->updatePaths();
if ($paths !== false) {
$this->info('Paths checked successfully');
}

if ($this->addAdminUser()) {
File::put(base_path().'/_install/install.lock', 'application install locked on '.now());
$this->info('Generating application key');
$this->call('key:generate', ['--force' => true]);
$this->info('NNTmux installation completed successfully');
exit();
}

$this->error('NNTmux installation failed. Fix reported problems and try again');

}

/**
Expand All @@ -90,8 +97,7 @@ private function updatePaths()
$tmp_path = config('nntmux.tmp_path');
$unrar_path = config('nntmux_settings.unrar_path');

$nzbPathCheck = File::isWritable($nzb_path);
if (! $nzbPathCheck) {
if (! File::isWritable($nzb_path)) {
$this->warn($nzb_path.' is not writable. Please fix folder permissions');

return false;
Expand All @@ -104,33 +110,26 @@ private function updatePaths()
}
$this->info('Folder '.$unrar_path.' successfully created');
}
$unrarPathCheck = is_writable($unrar_path);
if ($unrarPathCheck === false) {

if (! is_writable($unrar_path)) {
$this->warn($unrar_path.' is not writable. Please fix folder permissions');

return false;
}

$coversPathCheck = File::isWritable($covers_path);
if (! $coversPathCheck) {
if (! File::isWritable($covers_path)) {
$this->warn($covers_path.' is not writable. Please fix folder permissions');

return false;
}

$tmpPathCheck = File::isWritable($tmp_path);
if (! $tmpPathCheck) {
if (! File::isWritable($tmp_path)) {
$this->warn($tmp_path.' is not writable. Please fix folder permissions');

return false;
}

return [
'nzb_path' => Str::finish($nzb_path, '/'),
'covers_path' => Str::finish($covers_path, '/'),
'unrar_path' => Str::finish($unrar_path, '/'),
'tmp_path' => Str::finish($tmp_path, '/'),
];
return true;
}

private function addAdminUser(): bool
Expand Down
Loading