Skip to content

Commit

Permalink
Merge pull request #4 from fphgov/develop
Browse files Browse the repository at this point in the history
Pre-release v1.0.0
  • Loading branch information
icetee authored Apr 30, 2023
2 parents 392c2b0 + 575e26c commit 2a3dbd4
Show file tree
Hide file tree
Showing 35 changed files with 451 additions and 258 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/release-develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
image: ${{ env.DOCKER_NGINX_IMAGE }}
build_file: ${{ env.DOCKER_NGINX_BUILD_FILE }}
path: .
target: app
registry: ${{ env.DOCKER_REGISTRY_URL }}
extra_args: "--skip-tls-verify"
username: ${{ secrets.DEV_NEXUS_USER }}
Expand Down Expand Up @@ -119,4 +120,14 @@ jobs:
helm_values_file: ${{ env.HELM_VALUES_FILE }}
helm_repository_upgrade_extra_args: |
--set php.image.tag=${{ needs.create-image-tag.outputs.imageTag }}
--set nginx.mage.tag=${{ needs.create-image-tag.outputs.imageTag }}
--set nginx.image.tag=${{ needs.create-image-tag.outputs.imageTag }}
--set env[0].value=${{ secrets.SMTP_NAME }}
--set env[1].value=${{ secrets.SMTP_HOST }}
--set env[2].value="${{ secrets.SMTP_PORT }}"
--set env[3].value=${{ secrets.SMTP_CONNECTION_CLASS }}
--set env[5].value=${{ secrets.SMTP_CONNECTION_CONFIG_PASSWORD }}
--set env[6].value=${{ secrets.SMTP_DEFAULTS_ADD_FROM }}
--set env[8].value=${{ secrets.SMTP_HEADERS_MESSAGE_ID_DOMAIN }}
--set env[10].value=${{ secrets.APP_EMAIL }}
--set env[11].value="${{ secrets.APP_PHONE }}"
--set env[13].value=${{ secrets.RECAPTCHA_SECRET }}
15 changes: 14 additions & 1 deletion .github/workflows/release-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
with:
image: ${{ env.DOCKER_PHP_IMAGE }}
build_file: ${{ env.DOCKER_PHP_BUILD_FILE }}
path: .
target: ${{ env.DOCKER_BUILD_TARGET }}
registry: ${{ env.DOCKER_REGISTRY_URL }}
extra_args: "--skip-tls-verify"
Expand All @@ -81,6 +82,8 @@ jobs:
with:
image: ${{ env.DOCKER_NGINX_IMAGE }}
build_file: ${{ env.DOCKER_NGINX_BUILD_FILE }}
path: .
target: app
registry: ${{ env.DOCKER_REGISTRY_URL }}
extra_args: "--skip-tls-verify"
username: ${{ secrets.PROD_NEXUS_USER }}
Expand Down Expand Up @@ -116,4 +119,14 @@ jobs:
helm_values_file: ${{ env.HELM_VALUES_FILE }}
helm_repository_upgrade_extra_args: |
--set php.image.tag=${{ needs.create-image-tag.outputs.imageTag }}
--set nginx.mage.tag=${{ needs.create-image-tag.outputs.imageTag }}
--set nginx.image.tag=${{ needs.create-image-tag.outputs.imageTag }}
--set env[0].value=${{ secrets.SMTP_NAME }}
--set env[1].value=${{ secrets.SMTP_HOST }}
--set env[2].value="${{ secrets.SMTP_PORT }}"
--set env[3].value=${{ secrets.SMTP_CONNECTION_CLASS }}
--set env[5].value=${{ secrets.SMTP_CONNECTION_CONFIG_PASSWORD }}
--set env[6].value=${{ secrets.SMTP_DEFAULTS_ADD_FROM }}
--set env[8].value=${{ secrets.SMTP_HEADERS_MESSAGE_ID_DOMAIN }}
--set env[10].value=${{ secrets.APP_EMAIL }}
--set env[11].value="${{ secrets.APP_PHONE }}"
--set env[13].value=${{ secrets.RECAPTCHA_SECRET }}
6 changes: 4 additions & 2 deletions bin/cron/notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

require 'vendor/autoload.php';

$dotenv = Dotenv\Dotenv::createUnsafeMutable(dirname(__DIR__, 2));
$dotenv->load();
if (getenv('NODE_ENV') === 'development') {
$dotenv = Dotenv\Dotenv::createUnsafeMutable(dirname(__DIR__, 2));
$dotenv->load();
}

$container = require 'config/container.php';

Expand Down
2 changes: 1 addition & 1 deletion config/autoload/app.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'url' => str_replace('"', '', getenv('APP_URL')),
'email' => str_replace('"', '', getenv('APP_EMAIL')),
'notification' => [
'frequency' => (int)getenv('APP_NOTIFICATION_FREQUENCY'),
'frequency' => (int)str_replace(['"',"'"], "", getenv('APP_NOTIFICATION_FREQUENCY')),
'mail' => [
'testTo' => getenv('APP_NOTIFICATION_MAIL_TESTTO'),
'subject' => getenv('APP_NOTIFICATION_MAIL_SUBJECT'),
Expand Down
2 changes: 1 addition & 1 deletion config/autoload/database.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'db' => [
'driver' => getenv('DB_DRIVER'),
'hostname' => getenv('DB_HOSTNAME'),
'port' => getenv('DB_PORT'),
'port' => (int)str_replace(['"',"'"], "", getenv('DB_PORT')),
'database' => getenv('DB_DATABASE'),
'user' => getenv('DB_USER'),
'password' => getenv('DB_PASSWORD'),
Expand Down
2 changes: 1 addition & 1 deletion config/autoload/doctrine.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'connection' => [
'orm_default' => [
'params' => [
'url' => 'mysql://'. getenv('DB_USER') .':'. getenv('DB_PASSWORD') .'@'. getenv('DB_HOSTNAME') . '/' . getenv('DB_DATABASE'),
'url' => 'mysql://'. getenv('DB_USER') .':'. getenv('DB_PASSWORD') .'@'. getenv('DB_HOSTNAME') . ':' . (int)str_replace(['"',"'"], "", getenv('DB_PORT')) . '/' . getenv('DB_DATABASE'),
'charset' => getenv('DB_CHARSET'),
'configuration' => []
],
Expand Down
102 changes: 2 additions & 100 deletions config/autoload/log.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,61 +24,6 @@
],
],
],
'stream' => [
'name' => 'stream',
'priority' => Laminas\Log\Logger::ALERT,
'options' => [
'stream' => __DIR__ . '/../../data/log/error.log',
'formatter' => [
'name' => Laminas\Log\Formatter\Simple::class
],
'filters' => [
'priority' => [
'name' => 'priority',
'options' => [
'operator' => '<=',
'priority' => Laminas\Log\Logger::INFO,
],
],
],
],
],
'db' => [
'name' => 'db',
'priority' => Laminas\Log\Logger::ALERT,
'options' => [
'db' => new Laminas\Db\Adapter\Adapter([
'driver' => getenv('DB_DRIVER'),
'database' => getenv('DB_DATABASE'),
'host' => getenv('DB_HOSTNAME'),
'username' => getenv('DB_USER'),
'password' => getenv('DB_PASSWORD'),
'port' => getenv('DB_PORT'),
]),
'table' => 'log_error',
'column' => [
'timestamp' => 'timestamp',
'priority' => 'priority',
'priorityName' => 'priorityName',
'message' => 'message',
],
'formatter' => [
'name' => Laminas\Log\Formatter\Db::class,
'options' => [
'dateTimeFormat' => 'Y-m-d h:i:s',
],
],
'filters' => [
'priority' => [
'name' => 'priority',
'options' => [
'operator' => '<=',
'priority' => Laminas\Log\Logger::INFO,
],
],
],
],
],
],
'processors' => [
'requestid' => [
Expand All @@ -89,56 +34,13 @@
'logger' => [
'AuditLogger' => [
'writers' => [
'stream' => [
'stdout' => [
'name' => 'stream',
'priority' => Laminas\Log\Logger::ALERT,
'options' => [
'stream' => __DIR__ . '/../../data/log/audit.log',
'stream' => 'php://stdout',
'formatter' => [
'name' => Laminas\Log\Formatter\Simple::class,
'options' => [
'format' => '%timestamp% %priorityName% (%priority%): %message% %extra%',
'dateTimeFormat' => 'c',
],
],
'filters' => [
'priority' => [
'name' => 'priority',
'options' => [
'operator' => '<=',
'priority' => Laminas\Log\Logger::INFO,
],
],
],
],
],
'db' => [
'name' => 'db',
'priority' => Laminas\Log\Logger::ALERT,
'options' => [
'db' => new Laminas\Db\Adapter\Adapter([
'driver' => getenv('DB_DRIVER'),
'database' => getenv('DB_DATABASE'),
'host' => getenv('DB_HOSTNAME'),
'username' => getenv('DB_USER'),
'password' => getenv('DB_PASSWORD'),
'port' => getenv('DB_PORT'),
]),
'table' => 'log_audit',
'column' => [
'timestamp' => 'timestamp',
'priority' => 'priority',
'priorityName' => 'priorityName',
'message' => 'message',
'extra' => [
'extra' => 'extra',
],
],
'formatter' => [
'name' => Laminas\Log\Formatter\Db::class,
'options' => [
'dateTimeFormat' => 'Y-m-d h:i:s',
],
],
'filters' => [
'priority' => [
Expand Down
2 changes: 1 addition & 1 deletion config/autoload/mail.global.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'smtp' => [
'name' => getenv('SMTP_NAME'),
'host' => getenv('SMTP_HOST'),
'port' => getenv('SMTP_PORT'),
'port' => (int)str_replace(['"',"'"], "", getenv('SMTP_PORT')),
'connection_class' => getenv('SMTP_CONNECTION_CLASS'),
'connection_config' => [
'username' => getenv('SMTP_CONNECTION_CONFIG_USERNAME'),
Expand Down
6 changes: 4 additions & 2 deletions config/cli-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

require_once BASIC_PATH . '/vendor/autoload.php';

$dotenv = Dotenv\Dotenv::createUnsafeMutable(BASIC_PATH);
$dotenv->load();
if (getenv('NODE_ENV') === 'development') {
$dotenv = Dotenv\Dotenv::createUnsafeMutable(dirname(__DIR__, 1));
$dotenv->load();
}

$container = require __DIR__ . '/container.php';

Expand Down
6 changes: 4 additions & 2 deletions config/object-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

require_once 'vendor/autoload.php';

$dotenv = Dotenv\Dotenv::createUnsafeMutable(dirname(__DIR__));
$dotenv->load();
if (getenv('NODE_ENV') === 'development') {
$dotenv = Dotenv\Dotenv::createUnsafeMutable(dirname(__DIR__, 1));
$dotenv->load();
}

$container = require __DIR__ . '/container.php';

Expand Down
15 changes: 11 additions & 4 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,24 @@
App\Handler\Account\CheckHandler::class
], 'app.api.account.check');
} else {
$app->post('/app/api/user/check', [
$app->post('/app/api/account/check', [
\Middlewares\Recaptcha::class,
App\Handler\account\CheckHandler::class
App\Handler\Account\CheckHandler::class
], 'app.api.account.check');
}

$app->get('/app/api/question', [
App\Middleware\AccountMiddleware::class,
$app->get('/app/api/question/{id:\d+}', [
App\Handler\Question\GetHandler::class
], 'app.api.question.get');

$app->get('/app/api/question/all', [
App\Handler\Question\GetAllHandler::class
], 'app.api.question.all');

$app->get('/app/api/question/navigation', [
App\Handler\Question\GetNavigationHandler::class
], 'app.api.question.navigation');

$app->post('/app/api/vote', [
App\Middleware\AccountMiddleware::class,
App\Handler\Vote\AddHandler::class
Expand Down
10 changes: 0 additions & 10 deletions docker/config/webapp/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,3 @@ if [ $MODE = "production" ]; then
fi

mkdir -p data/cache/DoctrineEntityProxy

if [[ ! -e data/log/audit.log ]]; then
mkdir -p data/log
touch data/log/audit.log
fi

if [[ ! -e data/log/error.log ]]; then
mkdir -p data/log
touch data/log/error.log
fi
52 changes: 50 additions & 2 deletions k8s/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,52 @@
FROM fphgov/nginx
FROM php:8.1-cli-alpine AS builder

# Locale
ENV LANG "C.UTF-8"
ENV LANGUAGE "C.UTF-8"
ENV LC_ALL "C.UTF-8"

RUN apk add --no-cache --update \
curl-dev \
git \
wget \
mysql-client \
libzip-dev \
supervisor \
autoconf \
make \
automake \
libtool \
pkgconfig \
bash \
zlib-dev \
icu-dev \
g++ \
libxml2-dev

RUN docker-php-ext-configure intl && docker-php-ext-install intl

ENV LIBRARY_PATH=/lib:/usr/lib

WORKDIR /var/www/html

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php -r "if (hash_file('sha384', 'composer-setup.php') === trim(file_get_contents('https://composer.github.io/installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
&& php composer-setup.php \
&& php -r "unlink('composer-setup.php');" \
&& mv composer.phar /usr/local/bin/composer

RUN docker-php-ext-install mysqli pdo pdo_mysql zip opcache && \
docker-php-ext-enable opcache

RUN apk add --no-cache cmake freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev && \
docker-php-ext-configure gd && \
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
docker-php-ext-install -j${NPROC} gd

COPY . .
RUN php -d allow_url_fopen=on /usr/local/bin/composer install --no-ansi --no-dev --no-interaction --no-progress --no-scripts --optimize-autoloader

FROM fphgov/nginx AS app

COPY ./k8s/nginx /etc/nginx/conf.d
COPY . /var/www/html
COPY --from=builder /var/www/html /var/www/html
3 changes: 3 additions & 0 deletions k8s/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,8 @@ RUN sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 25/' /usr/local/et
EXPOSE 9000

COPY supervisord.conf /etc/supervisord.conf
RUN chmod +x /var/www/html/docker/config/webapp/setup.sh

RUN php -d allow_url_fopen=on /usr/local/bin/composer install --no-ansi --no-dev --no-interaction --no-progress --no-scripts --optimize-autoloader

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
14 changes: 0 additions & 14 deletions k8s/php/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ done
if [ $MODE = "development" ]; then
cd /var/www/html

php -d allow_url_fopen=on /usr/local/bin/composer install

composer db-update

chmod 0644 bin/cron/notifications.php
Expand All @@ -22,21 +20,9 @@ fi
if [ $MODE = "production" ]; then
cd /var/www/html

php -d allow_url_fopen=on /usr/local/bin/composer install --no-ansi --no-dev --no-interaction --no-progress --no-scripts --optimize-autoloader

composer db-update

chmod 0644 bin/cron/notifications.php
fi

mkdir -p data/cache/DoctrineEntityProxy

if [[ ! -e data/log/audit.log ]]; then
mkdir -p data/log
touch data/log/audit.log
fi

if [[ ! -e data/log/error.log ]]; then
mkdir -p data/log
touch data/log/error.log
fi
1 change: 0 additions & 1 deletion migration/seed.sql

This file was deleted.

Loading

0 comments on commit 2a3dbd4

Please sign in to comment.