Skip to content

Commit

Permalink
Merge pull request #94 from mrysav/refactor-start-blis
Browse files Browse the repository at this point in the history
Refactor start-blis.sh and Dockerfile
  • Loading branch information
mrysav authored Sep 1, 2024
2 parents f67ca38 + f4aaf4c commit ff4d3fa
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 92 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ RUN echo "column-statistics = 0" | tee -a /etc/mysql/conf.d/mysqldump.cnf

# Copy the custom Apache2 config (blis.conf) into the
# Apache2 configuration directory. This will be enabled by the start-blis.sh
COPY docker/config/blis-release.conf /etc/apache2/blis-release.conf
COPY docker/config/blis-release.conf /etc/apache2/sites-available/blis-release.conf

# Enable Apache2 modules needed by application and disable default site
RUN a2enmod rewrite socache_shmcb ssl && a2dissite 000-default
RUN a2enmod rewrite socache_shmcb ssl && \
a2dissite 000-default && \
a2ensite blis*

# Copy custom PHP config into the container
COPY docker/config/php.ini /etc/php/5.6/apache2/php.ini
Expand All @@ -47,7 +49,8 @@ RUN mkdir /var/www/blis
COPY . /var/www/blis
RUN chown -R www-data:www-data /var/www && \
chmod +x /var/log/apache2 && \
chmod +r /var/log/apache2/*
chmod +r /var/log/apache2/* && \
echo ". /var/www/apache2_blis.env" | tee -a /etc/apache2/envvars

# Inject the current git commit SHA as a build parameter
# This isn't foolproof, but will help when someone is using the
Expand Down
13 changes: 0 additions & 13 deletions docker/bin/get-https-cert.sh

This file was deleted.

37 changes: 0 additions & 37 deletions docker/bin/set-apache2-servername.py

This file was deleted.

38 changes: 4 additions & 34 deletions docker/bin/start-blis.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,20 @@
#!/bin/bash

echo "Dumping environment variables to environment file..."

A2ENVVARS="$(env | grep -E "(^DB_|^BLIS_)" | sed -e 's/^/export /')"
echo "$A2ENVVARS" | sudo tee /etc/apache2/apache2_blis.env > /dev/null
echo "$A2ENVVARS" > /var/www/apache2_blis.env

GIT_COMMIT_SHA="$(cat /etc/blis_git_commit_sha 2>/dev/null)"
if [[ -n "$GIT_COMMIT_SHA" ]]; then
echo "export GIT_COMMIT_SHA=\"$GIT_COMMIT_SHA\"" | sudo tee -a /etc/apache2/apache2_blis.env
fi

if ! grep -q 'apache2_blis.env' /etc/apache2/envvars; then
echo "Adding BLIS environment variables to Apache2 configuration..."
echo ". /etc/apache2/apache2_blis.env" | sudo tee -a /etc/apache2/envvars
echo "export GIT_COMMIT_SHA=\"$GIT_COMMIT_SHA\"" >> /var/www/apache2_blis.env
fi

if [[ -d "/workspace" ]]; then
# add sticky bit so all files remain belonging to vscode:vscode
find /workspace -type d -exec sudo chmod ug+s {} \;
fi

# This is a little funky...
# The container build puts the config in /etc/apache2, but this is not the correct place for it.
# The reason for this is so you can mount a volume to /etc/apache2/sites-available to persist your changes.
# When the container starts, it will only overwrite the configuration with the default if the file doesn't
# exist already.
if [[ ! -f "/etc/apache2/sites-available/blis-release.conf" ]]; then
if [[ -f "/etc/apache2/blis-release.conf" ]]; then
echo -e "Thanks for setting up BLIS! Just getting some things in place..."
sudo mv /etc/apache2/blis-release.conf /etc/apache2/sites-available/blis-release.conf
# Set the ServerName properly, according to the environment
BLIS_APACHE2_CONFIG="/etc/apache2/sites-available/blis-release.conf" set-apache2-servername.py
else
if [[ ! -f "/etc/apache2/sites-available/blis.conf" ]]; then
echo "The blis-release.conf Apache2 configuration is not present. Did the container build correctly?"
exit 1
else
echo "Found blis.conf apache2 configuration - must be a dev container!"
fi
fi
fi

if [[ -f "/etc/apache2/sites-available/blis-release-le-ssl.conf" ]]; then
echo "Detected an SSL configuration!"
fi

sudo a2ensite blis*

sudo service apache2 start

echo "BLIS is running!"
10 changes: 5 additions & 5 deletions htdocs/includes/composer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require_once(dirname(__FILE__) . '/../../vendor/autoload.php');
require_once(__DIR__."/../../vendor/autoload.php");

# Logger setup

Expand All @@ -13,11 +13,11 @@
mkdir(__DIR__."/../../log", 0755);
}

$log = new Logger('application');
$log->pushHandler(new StreamHandler(dirname(__FILE__).'/../../log/application.log', Logger::DEBUG));
$log = new Logger("application");
$log->pushHandler(new StreamHandler(__DIR__."/../../log/application.log", Logger::DEBUG));

$db_log = new Logger('database');
$db_log->pushHandler(new StreamHandler(dirname(__FILE__).'/../../log/database.log', Logger::DEBUG));
$db_log = new Logger("database");
$db_log->pushHandler(new StreamHandler(__DIR__."/../../log/database.log", Logger::DEBUG));

# Check for other folders needed by application
if (!file_exists(__DIR__."/../../files")) {
Expand Down

0 comments on commit ff4d3fa

Please sign in to comment.