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

Adding docker as container service #1575

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ DirectoryIndex index.php

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^localhost [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# If storing your installation in a sub-folder, uncomment the following line (remove the # symbol) and replace [subfolder] with the name of your subfolder
Expand Down Expand Up @@ -118,4 +119,4 @@ Options +ExecCGI +Includes +IncludesNOEXEC +SymLinksIfOwnerMatch -Indexes
# Caching schema
<FilesMatch "\.(css|js)$">
Header set Cache-Control "max-age=3600"
</FilesMatch>
</FilesMatch>
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM php:7.3-apache

# Enable mod_rewrite, mod_headers, and other necessary modules
RUN a2enmod rewrite headers cgi include

# Install necessary PHP extensions, including mysqli
RUN docker-php-ext-install pdo_mysql mysqli

# Copy the source code
COPY ./ /var/www/html

# Set appropriate permissions
RUN chown -R www-data:www-data /var/www/html

# Set access permissions for the .htaccess file
RUN chmod -R 755 /var/www/html/.htaccess

# Restart Apache to apply changes
CMD ["apache2-foreground"]
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3.8'

services:
web:
build: .
container_name: bcoe_web
ports:
- "80:80"
- "443:443"
volumes:
- ./:/var/www/html
environment:
- DB_HOST=bcoe_db
- DB_USER=root
- DB_PASSWORD=rootpassword
- DB_NAME=brewing_competition
- DB_PORT=3306 # You can change if you need
depends_on:
- db

db:
image: mysql:5.7
container_name: bcoe_db
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: brewing_competition
MYSQL_USER: bcoe_user
MYSQL_PASSWORD: bcoe_password
volumes:
- db_data:/var/lib/mysql

volumes:
db_data:
12 changes: 6 additions & 6 deletions site/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* *** https://www.godaddy.com/help/viewing-your-database-details-with-shared-hosting-accounts-39
*/

$hostname = 'localhost';
$hostname = getenv('DB_HOST') ?: 'localhost';

/**
* Enter the username for your database (generally the same as your login code
Expand All @@ -31,7 +31,7 @@
*/


$username = '';
$username = getenv('DB_USER') ?: '';


/**
Expand All @@ -40,15 +40,15 @@
* $password = 'flintsone'.
*/

$password = '';
$password = getenv('DB_PASSWORD') ?: '';

/**
* The following line is the name of your MySQL database you set up already.
* If you haven't set up the database yet, please refer to
* http://brewingcompetitions.com/install-instructions for setup instructions.
*/

$database = '';
$database = getenv('DB_NAME') ?: '';


/**
Expand All @@ -57,7 +57,7 @@
* Example: $database_port = 3308;
*/

$database_port = ini_get('mysqli.default_port');
$database_port = getenv('DB_PORT') ?: ini_get('mysqli.default_port');

/**
* This line strings the information together and connects to MySQL.
Expand Down Expand Up @@ -209,4 +209,4 @@
$server_root = $_SERVER['DOCUMENT_ROOT'];
//$server_root = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];

?>
?>