Docker updates

This commit is contained in:
Joey Kimsey
2024-08-14 17:41:15 -04:00
parent 156f19ee97
commit b6767ae846
11 changed files with 191 additions and 139 deletions

View File

@ -4,15 +4,14 @@ volumes:
db-data: db-data:
services: services:
# Database Server ttp-database:
database:
container_name: TTP-MySQL container_name: TTP-MySQL
image: mysql:8.0 image: mysql:8.0
ports: ports:
- ${DOCKER_DB_PORT}:3306 - ${DOCKER_DB_PORT}:3306
environment: environment:
MYSQL_ROOT_PASSWORD: ${DOCKER_DB_PASSWORD} MYSQL_ROOT_PASSWORD: ${DOCKER_DB_PASSWORD}
MYSQL_DATABASE: ${DB_DATABASE} MYSQL_DATABASE: ${DOCKER_DB_DATABASE}
MYSQL_USER: ${DOCKER_DB_USERNAME} MYSQL_USER: ${DOCKER_DB_USERNAME}
MYSQL_PASSWORD: ${DOCKER_DB_PASSWORD} MYSQL_PASSWORD: ${DOCKER_DB_PASSWORD}
volumes: volumes:
@ -23,7 +22,7 @@ services:
timeout: 10s timeout: 10s
retries: 10 retries: 10
phpmyadmin: ttp-phpmyadmin:
container_name: TTP-PhpMyAdmin container_name: TTP-PhpMyAdmin
image: phpmyadmin:latest image: phpmyadmin:latest
ports: ports:
@ -32,56 +31,27 @@ services:
environment: environment:
PMA_HOST: database PMA_HOST: database
depends_on: depends_on:
database: ttp-database:
condition: service_healthy condition: service_healthy
# NGINX
webone: ttp-nginx:
container_name: TTP-Nginx container_name: TTP-Nginx
build: build:
context: . context: .
dockerfile: ./docker/Dockerfile dockerfile: ./docker/ttp-nginx/Dockerfile
target: nginx target: php-fpm
volumes:
- ./:/var/www/html
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
ports: ports:
- "8080:80" - "8080:80"
links: environment:
- php - APP_ENV=${APP_ENV}
depends_on:
- php
# apache ttp-apache:
webtwo:
container_name: TTP-Apache container_name: TTP-Apache
build: build:
context: . context: .
dockerfile: ./docker/Dockerfile dockerfile: ./docker/ttp-apache/Dockerfile
target: apache target: apache
volumes:
- ./:/var/www/html
- ./docker/apache.conf:/etc/apache2/sites-available/000-default.conf
ports: ports:
- "8000:80" - "8000:80"
environment: environment:
- APP_ENV=${APP_ENV} - APP_ENV=${APP_ENV}
depends_on:
- php
# php
php:
container_name: TTP-Php
build:
context: .
dockerfile: ./docker/Dockerfile
target: php-fpm
working_dir: /var/www/html
volumes:
- ./:/var/www/html
ports:
- "9000:9000"
environment:
- APP_ENV=${APP_ENV}
depends_on:
database:
condition: service_healthy

View File

@ -1,6 +1,5 @@
APP_ENV = "docker" APP_ENV = "docker"
DOCKER_APP_PORT = 8000
DOCKER_DB_PORT = 3306 DOCKER_DB_PORT = 3306
DOCKER_DB_USERNAME = dbadmin DOCKER_DB_USERNAME = dbadmin
DOCKER_DB_PASSWORD = secret DOCKER_DB_PASSWORD = secret
DB_DATABASE = ttp DOCKER_DB_DATABASE = ttp

View File

@ -1,11 +0,0 @@
FROM nginx:latest as nginx
FROM php:8-fpm as php-fpm
RUN apt-get update -y
RUN apt-get install -y libmariadb-dev
RUN docker-php-ext-install mysqli pdo pdo_mysql
FROM php:8-apache as apache
RUN a2enmod ssl && a2enmod rewrite
RUN docker-php-ext-install mysqli pdo pdo_mysql
WORKDIR /var/www/html

View File

@ -1,11 +0,0 @@
ServerName localhost
<VirtualHost *:80>
ServerAdmin admin@localhost
DocumentRoot /var/www/html/
<Directory /var/www/html/>
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

View File

@ -1,73 +0,0 @@
server {
listen 80 default_server;
index index.php;
server_name TheTempusProject;
error_log /var/www/html/logs/nginx-error.log;
access_log /var/www/html/logs/nginx-access.log;
root /var/www/html;
charset utf-8;
sendfile off;
client_max_body_size 100m;
location /js/ {
access_log off;
log_not_found off;
try_files $uri /index.php?error=js404&file=$uri;
}
location /css/ {
access_log off;
log_not_found off;
try_files $uri /index.php?error=css404&file=$uri;
}
location /images/ {
try_files $uri /index.php?error=image404&url=$uri;
}
location /uploads/ {
try_files $uri /index.php?error=upload404&url=$uri;
}
location /errors/ {
try_files $uri /index.php?error=$uri;
}
location ~* \.(?:js|css|png|jpg|gif|ico)$ {
access_log off;
log_not_found off;
}
location = /favicon.ico {
access_log off;
log_not_found off;
rewrite ^(.+)$ /images/favicon.ico break;
}
location = /robots.txt {
allow all;
access_log off;
log_not_found off;
rewrite ^(.+)$ /bin/robots.txt break;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 60s;
fastcgi_read_timeout 60s;
fastcgi_send_timeout 60s;
}
location / {
rewrite ^/(.+)$ /index.php?url=$1&$args last;
}
}

View File

@ -0,0 +1,13 @@
FROM php:8-apache as apache
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN apt-get update -y
RUN apt-get install git libzip-dev -y
RUN a2enmod ssl && a2enmod rewrite
RUN docker-php-ext-install mysqli pdo pdo_mysql zip
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /var/www
RUN rm -rf html/
RUN composer create-project thetempusproject/thetempusproject html
RUN chmod -R 777 html/
RUN chown -R www-data:www-data html/

View File

@ -0,0 +1,19 @@
Build the image
```
docker build -t thetempusproject/ttp-apache:latest .
docker build --no-cache -t thetempusproject/ttp-apache:latest .
```
Set the proper tag for dockerhub
```
docker tag ttp-apache:latest thetempusproject/ttp-apache:latest
```
Run the image
```
docker run -d -p 80:80 thetempusproject/ttp-apache
```

View File

@ -0,0 +1,29 @@
FROM php:8-fpm as php-fpm
# Env
ENV COMPOSER_ALLOW_SUPERUSER=1
# Install Packages
RUN apt-get update -y
RUN apt-get install -y nginx libmariadb-dev git libzip-dev zip unzip supervisor
RUN docker-php-ext-install mysqli pdo pdo_mysql zip
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
#Install TTP
WORKDIR /var/www
RUN rm -rf html/
RUN composer create-project thetempusproject/thetempusproject html
RUN chmod -R 777 html/
RUN chown -R www-data:www-data html/
# Copy Nginx configuration file
RUN cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
COPY ./docker/ttp-nginx/nginx.conf /etc/nginx/nginx.conf
# Copy Supervisor configuration file
COPY ./docker/ttp-nginx/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Start Supervisor, which will start both Nginx and PHP-FPM
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

View File

@ -0,0 +1,19 @@
Build the image
```
docker build -t thetempusproject/ttp-nginx:latest .
docker build --no-cache -t thetempusproject/ttp-nginx:latest .
```
Set the proper tag for dockerhub
```
docker tag ttp-nginx:latest thetempusproject/ttp-nginx:latest
```
Run the image
```
docker run -d -p 8000:80 thetempusproject/ttp-nginx
```

View File

@ -0,0 +1,90 @@
user www-data;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
tcp_nopush on;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
gzip on;
server {
listen 80 default_server;
index index.php;
server_name TheTempusProject;
root /var/www/html;
charset utf-8;
sendfile on;
client_max_body_size 100m;
location /js/ {
access_log off;
log_not_found off;
try_files $uri /index.php?error=js404&file=$uri;
}
location /css/ {
try_files $uri /index.php?error=css404&file=$uri;
}
location /images/ {
try_files $uri /index.php?error=image404&url=$uri;
}
location /uploads/ {
try_files $uri /index.php?error=upload404&url=$uri;
}
location /errors/ {
try_files $uri /index.php?error=$uri;
}
location = /favicon.ico {
access_log off;
log_not_found off;
rewrite ^(.+)$ /images/favicon.ico break;
}
location = /robots.txt {
allow all;
access_log off;
log_not_found off;
rewrite ^(.+)$ /bin/robots.txt break;
}
location ~* \.(?:js|css|png|jpg|gif|ico)$ {
access_log off;
log_not_found off;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
include snippets/fastcgi-php.conf;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 60s;
fastcgi_read_timeout 60s;
fastcgi_send_timeout 60s;
}
location / {
rewrite ^/(.+)$ /index.php?url=$1&$args last;
}
}
include /etc/nginx/conf.d/*.conf;
}

View File

@ -0,0 +1,8 @@
[supervisord]
nodaemon=true
[program:php-fpm]
command=/usr/local/sbin/php-fpm
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'