Skip to content

Commit 8627c24

Browse files
author
bugfish\bugfishtm
committed
1.10.100
1 parent 7294dd7 commit 8627c24

File tree

10 files changed

+161
-35
lines changed

10 files changed

+161
-35
lines changed

_docker/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This is necessary, to make cronjobs work that act without docker env initializations.
44

55
# Database Password for Root Account
6+
# Do not use ' / " in passwords
67
sf_db_pass=secretdbpassword
78

89
# Public URL where this website will be visible on.

_docker/Dockerfile

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@
33
############################################################################################################
44
FROM php:8.4-apache
55

6-
######################################################
7-
# Update APT Library
8-
######################################################
6+
############################################################################################################
7+
# Update APT Library and Upgrade System
8+
############################################################################################################
99
RUN apt update -y
10-
11-
######################################################
12-
# Upgrade System
13-
######################################################
1410
RUN apt upgrade -y
1511

16-
######################################################
12+
############################################################################################################
1713
# Install Dependencies
18-
######################################################
14+
############################################################################################################
1915
RUN apt install apache2 -y
2016
RUN apt install curl -y
2117
RUN apt install cron -y
@@ -25,14 +21,13 @@ RUN apt install libpng-dev -y
2521
RUN apt install zlib1g-dev -y
2622
RUN apt install libcurl4-openssl-dev -y
2723
RUN apt install openssl -y
28-
RUN apt install openssl -y
2924
RUN apt install libicu-dev -y
3025
RUN apt install libxml2-dev -y
3126
RUN apt install libzip-dev -y
3227

33-
######################################################
28+
############################################################################################################
3429
# Install PHP Extensions
35-
######################################################
30+
############################################################################################################
3631
RUN docker-php-ext-install mysqli
3732
RUN docker-php-ext-install curl
3833
RUN docker-php-ext-install bcmath
@@ -45,9 +40,9 @@ RUN docker-php-ext-install zip
4540
RUN docker-php-ext-install ctype
4641
RUN docker-php-ext-install filter
4742

48-
######################################################
43+
############################################################################################################
4944
# Set Timezone
50-
######################################################
45+
############################################################################################################
5146
ENV TZ=${sf_timezone}
5247
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo "$TZ" > /etc/timezone
5348

@@ -82,29 +77,51 @@ COPY _source/ /var/www/html/
8277
# Generate Default Apache2 Certificate (Self Signed)
8378
######################################################
8479
RUN mkdir -p /opt/sf_ssl
85-
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
86-
-keyout /opt/sf_ssl/privkey.pem \
87-
-out /opt/sf_ssl/cert.pem \
88-
-subj "/C=US/ST=State/L=City/O=Organization/OU=OrgUnit/CN=example.com"
8980

9081
############################################################################################################
9182
# Install MySQL
9283
############################################################################################################
9384
ENV DEBIAN_FRONTEND=noninteractive
9485
RUN apt install mariadb-client -y
9586
RUN apt install mariadb-server -y
96-
ENV MYSQL_ROOT_PASSWORD=${sf_db_pass}
97-
ENV MYSQL_DATABASE=${sf_db_name}
9887
RUN echo "[mysqld]\n\
9988
skip-networking=0\n\
10089
bind-address=0.0.0.0" > /etc/mysql/mariadb.conf.d/99-custom.cnf
10190

91+
############################################################################################################
92+
# Setup Website Cronjob Hourly with Root Access
93+
############################################################################################################
94+
RUN echo "0 * * * * /usr/local/bin/php /var/www/html/cronjob.php 2>&1" >> /etc/cron.d/my-cron-jobs
95+
96+
############################################################################################################
97+
# Install Supervisor
98+
############################################################################################################
99+
RUN apt-get install -y supervisor
100+
COPY ./_script/suitefish_cron.conf /etc/supervisor/conf.d/suitefish_cron.conf
101+
COPY ./_script/suitefish_apache2.conf /etc/supervisor/conf.d/suitefish_apache2.conf
102+
COPY ./_script/suitefish_mysql.conf /etc/supervisor/conf.d/suitefish_mysql.conf
103+
COPY ./_script/suitefish_suitefish.conf /etc/supervisor/conf.d/suitefish_suitefish.conf
104+
105+
############################################################################################################
106+
# Copy Entrypoint Script
107+
############################################################################################################
108+
COPY ./_script/entrypoint.sh /entrypoint.sh
109+
RUN chmod +x /entrypoint.sh
110+
COPY ./_script/restart_mysql.sh /restart_mysql.sh
111+
RUN chmod +x /restart_mysql.sh
112+
113+
############################################################################################################
114+
# Cleanup Image
115+
############################################################################################################
116+
RUN apt-get clean
117+
RUN rm -rf /var/lib/apt/lists/*
118+
119+
############################################################################################################
120+
# Add Entrypoint
121+
############################################################################################################
122+
ENTRYPOINT ["/entrypoint.sh"]
123+
102124
############################################################################################################
103125
# Startup Instructions
104126
############################################################################################################
105-
CMD service mariadb start && \
106-
chmod 0770 /var/www -R && \
107-
chown www-data:www-data /var/www -R && \
108-
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('${sf_db_pass}');" && \
109-
mysql -u root -p${sf_db_pass} -e "CREATE DATABASE IF NOT EXISTS ${sf_db_name};" && \
110-
apachectl -D FOREGROUND
127+
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf", "--silent"]

_docker/_script/entrypoint.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/sh
2+
# Promotion
3+
echo "------------------------------------------"
4+
echo "-- Bugfish / Suitefish Software"
5+
echo "-- I wish you the best."
6+
echo "-- Visit www.bugfish.eu!"
7+
echo "------------------------------------------"
8+
9+
# Your startup commands here
10+
echo "[OK] Executing entry point..."
11+
12+
# Check for created SSL Certificate
13+
if [ ! -f "/opt/sf_ssl/privkey.pem" ] && [ ! -f "/opt/sf_ssl/cert.pem" ]; then
14+
echo "[OK] Creating custom ssl certificate.."
15+
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
16+
-keyout /opt/sf_ssl/privkey.pem \
17+
-out /opt/sf_ssl/cert.pem \
18+
-subj "/C=US/ST=State/L=City/O=Organization/OU=OrgUnit/CN=example.com" > /dev/null 2>&1
19+
echo "[OK] Custom SSL certificate generated...";
20+
else
21+
echo "[OK] SSL Certificate found...";
22+
fi
23+
24+
# Setting Permissions
25+
echo "[OK] Setting up permissions on /var/www to 0770 recursively...";
26+
chmod 0770 /var/www -R > /dev/null 2>&1
27+
echo "[OK] Setting up ownership to www-data on /var/www recursively...";
28+
chown www-data:www-data /var/www -R > /dev/null 2>&1
29+
echo "[OK] Setting up permissions on /etc/cron.d/my-cron-jobs to 0644...";
30+
chmod 0644 /etc/cron.d/my-cron-jobs > /dev/null 2>&1
31+
32+
# Wait for Supervisor to start cron
33+
echo "[OK] Start database service...";
34+
service mariadb start > /dev/null 2>&1
35+
echo "[OK] Start cron service...";
36+
service cron start > /dev/null 2>&1
37+
38+
# Wait for Supervisor to start cron
39+
echo "[OK] Idle time for services 5 seconds...";
40+
sleep 5
41+
42+
# Activate Cronjob File
43+
echo "[OK] Activate Cronjob File /etc/cron.d/my-cron-jobs...";
44+
crontab /etc/cron.d/my-cron-jobs
45+
46+
# Default MySQL Initializations
47+
echo "[OK] Updating mysql root users password..."
48+
mysql -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$sf_db_pass';" > /dev/null 2>&1
49+
echo "[OK] Creating initial database if not exists..."
50+
mysql -u root -p"$sf_db_pass" -e "CREATE DATABASE IF NOT EXISTS suitefish;" > /dev/null 2>&1
51+
52+
# Wait for Supervisor to start cron
53+
echo "[OK] Stop cron services to be started by supervisor...";
54+
service cron stop > /dev/null 2>&1
55+
56+
# Wait for Supervisor to start cron
57+
echo "[OK] Idle time to cron service to stop...";
58+
sleep 5
59+
60+
# Your finish commands here
61+
echo "[OK] Finished Executing Entry Point..."
62+
63+
# Execute the main CMD Dockerfile command passed to the container
64+
echo "[OK] Starting main container prompt....";
65+
exec "$@"

_docker/_script/restart_mysql.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
while true; do
3+
if ! systemctl is-active --quiet mariadb; then
4+
service mariadb restart
5+
fi
6+
sleep 120
7+
done
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[program:apache2]
2+
command=/usr/sbin/apache2ctl -D FOREGROUND
3+
autostart=true
4+
autorestart=true
5+
stdout_logfile=/dev/stdout
6+
stdout_logfile_maxbytes=0
7+
stderr_logfile=/dev/stderr
8+
stderr_logfile_maxbytes=0
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:cron]
5+
command=/usr/sbin/cron -f
6+
autostart=true
7+
autorestart=true
8+
stdout_logfile=/dev/stdout
9+
stdout_logfile_maxbytes=0
10+
stderr_logfile=/dev/stderr
11+
stderr_logfile_maxbytes=0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[program:mysql]
2+
command=/bin/sh /restart_mysql.sh
3+
autostart=true
4+
autorestart=true
5+
user=root
6+
stdout_logfile=/dev/stdout
7+
stdout_logfile_maxbytes=0
8+
stderr_logfile=/dev/stderr
9+
stderr_logfile_maxbytes=0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[program:suitefish]
2+
command=/usr/local/bin/php /var/www/html/_core/worker.php
3+
user=root
4+
autostart=true
5+
autorestart=true
6+
stderr_logfile=/var/log/suitefish_error.log
7+
stdout_logfile=/var/log/suitefish_log.log
8+
startsecs=0
9+
environment=SUITEFISH_SUPERVISOR_LOG_FILE="/var/log/suitefish_log.log"

_docker/_source/settings.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@
3131

3232
/* MySQL Settings */
3333
// MySQL Hostname, usually 'localhost' if your database is on the same server
34-
$mysql['host'] = getenv('sf_db_host');
34+
$mysql['host'] = "127.0.0.1";
3535

3636
// MySQL Port, the default port for MySQL is 3306
3737
$mysql['port'] = '3306';
3838

3939
// MySQL User, replace 'MYSQL_USER' with your actual MySQL username
40-
$mysql['user'] = getenv('sf_db_user');
40+
$mysql['user'] = "root";
4141

4242
// MySQL Password, replace 'MYSQL_PASSWORD' with your actual MySQL password
4343
$mysql['pass'] = getenv('sf_db_pass');
4444

4545
// MySQL Database, replace 'MYSQL_DATABASE' with the name of your database
46-
$mysql['db'] = getenv('sf_db_name');
46+
$mysql['db'] = "suitefish";
4747

4848
// Prefix for MySQL tables, this is useful if you're sharing the database with other applications
4949
$mysql['prefix'] = 'sf_';
@@ -59,7 +59,7 @@
5959
$object['url'] = getenv('sf_url');
6060

6161
/* Do not change below! */
62-
define("_HIVE_IS_IN_DOCKER_", true);
62+
if(!defined("_HIVE_IS_IN_DOCKER_")) { define("_HIVE_IS_IN_DOCKER_", true); }
6363

6464
/* Do not change below! */
6565
// Check if the core initialization file exists and require it if it does

_docker/docker-compose.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
services:
22
obr:
33
build: .
4-
image: obr:1.10.100
4+
image: bugfishtm/obr:latest
55
volumes:
6+
- ssl:/opt/sf_ssl
67
- data:/var/www/html/_data
78
- mysql:/var/lib/mysql
89
ports:
910
- 80:80
1011
- 443:443
1112
environment:
12-
sf_db_host: "127.0.0.1"
13-
sf_db_user: "root"
1413
sf_db_pass: "${sf_db_pass}"
15-
sf_db_name: "suitefish"
1614
sf_url: "${sf_url}"
1715
sf_timezone: "${sf_timezone}"
1816
volumes:
1917
mysql:
20-
data:
18+
data:
19+
ssl:

0 commit comments

Comments
 (0)