Skip to content

Commit

Permalink
minimize docker layers, send to setup on clean install
Browse files Browse the repository at this point in the history
  • Loading branch information
antedebaas committed Jan 20, 2024
1 parent e12ce51 commit 53f1aad
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 44 deletions.
71 changes: 36 additions & 35 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,50 @@ ENV MAILER_SMTPPORT=25
ENV MAILER_IMAPPORT=993
ENV MAILER_USER=
ENV MAILER_PASSWORD=
ENV DELETE_PROCESSED_MAILS=
ENV DELETE_PROCESSED_MAILS=false

RUN apk --update add ca-certificates
RUN apk --no-cache add \
RUN apk --update add ca-certificates && \
apk --no-cache add \
curl \
nginx \
php81 \
php81-ctype \
php81-dom \
php81-fileinfo \
php81-fpm \
php81-iconv \
php81-imap \
php81-mbstring \
php81-pdo \
php81-pdo_mysql \
php81-pdo_pgsql \
php81-pdo_sqlite \
php81-phar \
php81-session \
php81-simplexml \
php81-tokenizer \
php81-xml \
php81-xmlwriter \
php81-zip \
php83 \
php83-ctype \
php83-dom \
php83-fileinfo \
php83-fpm \
php83-iconv \
php83-imap \
php83-mbstring \
php83-pdo \
php83-pdo_mysql \
php83-pdo_pgsql \
php83-pdo_sqlite \
php83-phar \
php83-session \
php83-simplexml \
php83-tokenizer \
php83-xml \
php83-xmlwriter \
php83-zip \
supervisor

COPY dockerfiles/nginx.conf /etc/nginx/nginx.conf
COPY dockerfiles/fpm-pool.conf /etc/php81/php-fpm.d/www.conf
COPY dockerfiles/php.ini /etc/php81/conf.d/custom.ini
COPY dockerfiles/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY dockerfiles/containerstartup.sh /usr/local/bin/containerstartup.sh
RUN chmod +x /usr/local/bin/containerstartup.sh
COPY dockerfiles/checkmail.sh /etc/periodic/daily/checkmail.sh
RUN chmod +x /etc/periodic/daily/checkmail.sh
COPY dockerfiles/ /

RUN chmod +x /usr/local/bin/containerstartup.sh && \
dos2unix /usr/local/bin/containerstartup.sh && \
chmod +x /etc/periodic/daily/checkmail.sh && \
dos2unix /etc/nginx/nginx.conf && \
dos2unix /etc/php83/php-fpm.d/www.conf && \
dos2unix /etc/php83/conf.d/custom.ini && \
dos2unix /etc/supervisor/conf.d/supervisord.conf && \
mkdir -p /var/www/html && \
ln -s /usr/bin/php83 /usr/bin/php && \
ln -s /usr/sbin/php-fpm83 /usr/sbin/php-fpm

RUN mkdir -p /var/www/html
WORKDIR /var/www/html
COPY --chown=nobody . /var/www/html/

RUN ln -s /usr/bin/php81 /usr/bin/php
RUN wget https://getcomposer.org/composer-stable.phar -O /usr/local/bin/composer && chmod +x /usr/local/bin/composer
RUN /usr/local/bin/composer install
RUN wget https://getcomposer.org/composer-stable.phar -O /usr/local/bin/composer && chmod +x /usr/local/bin/composer && \
/usr/local/bin/composer install

RUN chown -R nobody.nobody /var/www/html && \
chown -R nobody.nobody /run && \
Expand Down
31 changes: 25 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
name: dmarc-smtptls-reports
version: "2"
services:
dmarc-reports:
image: antedebaas/dmarc-reports:latest
db:
image: mariadb:latest
environment:
MYSQL_DATABASE:
MYSQL_USER:
MYSQL_PASSWORD:
MYSQL_ROOT_PASSWORD:
ports:
- 3306
restart: unless-stopped
healthcheck:
test: [ "CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized" ]
interval: 10s
timeout: 5s
retries: 6
web:
image: antedebaas/dmarc-reports-local:latest
ports:
- 0.0.0.0:8080:8080
environment:
DATABASE_TYPE: mysql
DATABASE_HOST:
DATABASE_PORT: 3306
DATABASE_NAME: dmarcreports
DATABASE_HOST: db
DATABASE_PORT: 3306
DATABASE_NAME:
DATABASE_USER:
DATABASE_PASSWORD:
MAILER_HOST:
MAILER_SMTPPORT: 25
MAILER_SMTPPORT: 587
MAILER_IMAPPORT: 993
MAILER_USER:
MAILER_PASSWORD:
restart: unless-stopped
depends_on:
db:
condition: service_healthy
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ http {
root /var/lib/nginx/html;
}

# Pass the PHP scripts to PHP-FPM listening on 127.0.0.1:9000
# Pass the PHP scripts to PHP-FPM listening on /run/php-fpm.sock
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ autorestart=true
startretries=0

[program:php-fpm]
command=/usr/sbin/php-fpm81 -F
command=/usr/sbin/php-fpm -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions src/Controller/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

use App\Entity\Users;
use App\Entity\Domains;
use App\Entity\DMARC_Reports;
use App\Entity\DMARC_Seen;
Expand Down Expand Up @@ -37,6 +38,11 @@ public function index(): Response
return $this->redirectToRoute('app_setup');
}

$repository = $this->em->getRepository(Users::class);
if($repository->count([]) == 0) {
return $this->redirectToRoute('app_setup');
}

if (!$this->getUser()) {
return $this->redirectToRoute('app_login');
}
Expand Down
9 changes: 8 additions & 1 deletion src/Controller/RegistrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,23 @@

class RegistrationController extends AbstractController
{
private $em;
private EmailVerifier $emailVerifier;

public function __construct(EmailVerifier $emailVerifier)
public function __construct(EntityManagerInterface $em, EmailVerifier $emailVerifier)
{
$this->em = $em;
$this->emailVerifier = $emailVerifier;
}

#[Route('/register', name: 'app_register')]
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, UserAuthenticatorInterface $userAuthenticator, Authenticator $authenticator, EntityManagerInterface $entityManager): Response
{
$repository = $this->em->getRepository(Users::class);
if(!file_exists(dirname(__FILE__).'/../../.env.local') || $repository->count([]) == 0) {
return $this->redirectToRoute('app_setup');
}

$user = new Users();
$form = $this->createForm(RegistrationFormType::class, $user);
$form->handleRequest($request);
Expand Down

0 comments on commit 53f1aad

Please sign in to comment.