Skip to content

Commit

Permalink
Merge pull request #130 from wetfish/fix_dockerized_url
Browse files Browse the repository at this point in the history
Fix dockerized url
  • Loading branch information
itsrachelfish authored Mar 19, 2021
2 parents dea9276 + d0c9ef0 commit d8756f6
Show file tree
Hide file tree
Showing 9 changed files with 2,305 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
DB_PASSWORD=secret
DB_DATABASE=forums
DB_USERNAME=forums

# Set to 1 to enable maintenance mode, 2 to make it immutable
MAINTENANCE_MODE=0
MAINTENANCE_TITLE="Maintenance Mode"
MAINTENANCE_MESSAGE="Okay faithful users...we're attempting to restore an older backup of the database...news will be posted once we're back"

SITE_NAME=forums
SITE_LANGUAGE=english

# These sites are expected to live at your.url/forum, please make sure your url has the correct structure
SITE_URL=https://staging.wetfishonline.com/forum

OUTGOING_EMAIL=noreply@yourdomain.com
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Go to the base directory of this repo:
Import the database schema:
``mysql -u root -p {db_name} < setup/schema.sql``

## Running with docker

1. Create a **.env** based on the `.env.example` provided
2. Run `docker-compose up -d`

## Repair database settings:
First, in the ``forum`` directory of this repo, copy Settings.example.php to Settings.php
``cp forum/Settings.example.php forum/Settings.php``
Expand Down
2,086 changes: 2,086 additions & 0 deletions config/docker.sql

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions config/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
server {
listen 80;

index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;

root /var/www;
location /forum/ { }

location = / {
rewrite ^/(.*)$ /forum/$1 redirect;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass forum:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
3 changes: 3 additions & 0 deletions config/php.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
php_admin_flag[log_errors] = on
php_admin_value[error_log] = /var/www/forum/errors.log
catch_workers_output = yes
1 change: 1 addition & 0 deletions config/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
date.timezone = UTC
94 changes: 94 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
version: '3'
services:

#PHP Service
forum:
image: fishnet/online
container_name: forum-php
restart: unless-stopped
tty: true
working_dir: /var/www/forum
env_file:
- ./.env
volumes:
- ./forum:/var/www/forum
- ./utils:/var/www/utils
- ./config/php.ini:/usr/local/etc/php/conf.d/settings.ini
- ./config/php.conf:/usr/local/etc/php-fpm.d/zz-php.conf
networks:
- forum-network
depends_on:
- db

webserver:
image: nginx:alpine
container_name: forum-nginx
restart: unless-stopped
ports:
- "80:80"
volumes:
- ./forum:/var/www/forum
- ./config/nginx.conf:/etc/nginx/conf.d/default.conf
networks:
- forum-network
depends_on:
- db
- forum

##SSL-enabled Nginx Service; uncomment to use
##Make sure to comment out the above webserver block
#webserver:
# image: ghcr.io/linuxserver/swag
# container_name: swag
# restart: unless-stopped
# environment:
# PUID: 1000
# PGID: 1000
# TZ: $TIMEZONE
# URL: $SITE_URL
# SUBDOMAINS: $SUBDOMAINS
# ONLY_SUBDOMAINS: $ONLY_SUBDOMAINS
# VALIDATION: http
# EMAIL: $EMAIL # optional
# ports:
# - "80:80"
# - "443:443"
# volumes:
# - ./swag/site-confs:/config/nginx/site-confs
# - ./swag/fastcgi_params:/config/nginx/fastcgi_params
# - ./laravel/:/config/www
# - config:/config
# networks:
# - forum-network
# depends_on:
# - db
# - forum

# MySQL Service
db:
image: mariadb
container_name: forum-mysql
restart: unless-stopped
command: --sql_mode=""
environment:
MYSQL_ROOT_PASSWORD: $DB_PASSWORD
MYSQL_DATABASE: $DB_DATABASE
MYSQL_USER: $DB_USERNAME
MYSQL_PASSWORD: $DB_PASSWORD
volumes:
- ./config/docker.sql:/docker-entrypoint-initdb.d/setup.sql
- dbdata:/var/lib/mysql
networks:
- forum-network

#Docker Networks
networks:
forum-network:
driver: bridge

#Volumes
volumes:
dbdata:
driver: local
node_modules:
driver: local
18 changes: 18 additions & 0 deletions forum/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM php:5.6-fpm-stretch

# Check what we need from staging here, build out php extensions
RUN apt-get update && apt-get install -y \
apt-utils \
libpng-dev \
libfreetype6-dev \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/freetype2/ \
&& docker-php-ext-configure calendar \
&& docker-php-ext-install calendar exif gd gettext mysql mysqli pdo_mysql

RUN useradd fishy
COPY --chown=fishy:fishy . /var/www/forum

USER fishy

EXPOSE 9000
CMD ["php-fpm"]
58 changes: 58 additions & 0 deletions forum/Settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/**
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines http://www.simplemachines.org
* @copyright 2011 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.0
*/

########## Maintenance ##########
# Note: If $maintenance is set to 2, the forum will be unusable! Change it to 0 to fix it.
$maintenance = getenv('MAINTENANCE_MODE'); # Set to 1 to enable Maintenance Mode, 2 to make the forum untouchable. (you'll have to make it 0 again manually!)
$mtitle = getenv('MAINTENANCE_TITLE'); # Title for the Maintenance Mode message.
$mmessage = getenv('MAINTENANCE_MESSAGE'); # Description of why the forum is in maintenance mode.

########## Forum Info ##########
$mbname = getenv('SITE_NAME'); # The name of your forum.
$language = getenv('SITE_LANGUAGE'); # The default language file set for the forum.
$boardurl = getenv('SITE_URL'); # URL to your forum's folder. (without the trailing /!)
$webmaster_email = getenv('OUTGOING_EMAIL'); # Email address to send emails from. (like noreply@yourdomain.com.)
$cookiename = 'SMFCookie11'; # Name of the cookie to set for authentication.

########## Database Info ##########
$db_type = 'mysql';
$db_server = 'db';
$db_name = getenv('DB_DATABASE');
$db_user = getenv('DB_USERNAME');
$db_passwd = getenv('DB_PASSWORD');
$ssi_db_user = '';
$ssi_db_passwd = '';
$db_prefix = 'smf_';
$db_persist = 0;
$db_error_send = 1;

########## Directories/Files ##########
# Note: These directories do not have to be changed unless you move things.
$boarddir = '/home/halfwit/online/forum'; # The absolute path to the forum's folder. (not just '.'!)
$sourcedir = '/home/halfwit/online/forum/Sources'; # Path to the Sources directory.
$cachedir = '/home/halfwit/online/forum/cache'; # Path to the cache directory.

########## Error-Catching ##########
# Note: You shouldn't touch these settings.
$db_last_error = 0;

# Make sure the paths are correct... at least try to fix them.

if (!file_exists($boarddir) && file_exists(dirname(__FILE__) . '/agreement.txt'))
$boarddir = dirname(__FILE__);
if (!file_exists($sourcedir) && file_exists($boarddir . '/Sources'))
$sourcedir = $boarddir . '/Sources';
if (!file_exists($cachedir) && file_exists($boarddir . '/cache'))
$cachedir = $boarddir . '/cache';

?>

0 comments on commit d8756f6

Please sign in to comment.