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

PGOV-400: Config for deployment to cloud.gov #54

Merged
merged 25 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ba5b60f
apt-buildpack, php-buildpack, and node buildpack config for cloud.gov…
Jan 27, 2025
e84144a
PGOV-400: Manifest.yml with cloud.gov environment config for deployment.
Jan 27, 2025
787a93c
httpd basic auth config for drupal site.
Dec 18, 2024
a073e08
Basic auth for backend implemented in server config.
Dec 19, 2024
70edb36
httpd basic auth config for drupal site.
Dec 18, 2024
7beb82f
PGOV-400: Fixing directory structure of httpd config files.
Feb 4, 2025
be6332d
PGOV-400: executable bootstrap script.
Feb 4, 2025
27ee4e2
PGOV-400: remove unneeded frontend basic auth route.ts
Feb 4, 2025
f5ffabf
apt-buildpack, php-buildpack, and node buildpack config for cloud.gov…
Jan 27, 2025
10c87a2
httpd basic auth config for drupal site.
Dec 18, 2024
f4c6c34
Basic auth for backend implemented in server config.
Dec 19, 2024
9532fe6
httpd basic auth config for drupal site.
Dec 18, 2024
961582a
PGOV-400: Fixing directory structure of httpd config files.
Feb 4, 2025
8fb5a59
PGOV-400: executable bootstrap script.
Feb 4, 2025
68a7ea5
PGOV-400: remove unneeded frontend basic auth route.ts
Feb 4, 2025
639f3f0
Make sure preview works on dev site and turn off css and js aggregation.
Feb 6, 2025
5d52306
Updating php pre-commit checks to exclude frontend folder.
Feb 6, 2025
aa5ba54
Search and filter bar styling.
Feb 7, 2025
8029964
Make sure preview works on dev site and turn off css and js aggregation.
Feb 6, 2025
04aaa56
Remove unwanted changes to config
Feb 6, 2025
0952b3c
PGOV-400: getting rid of unneeded nginx config. Removing nano and sen…
Feb 10, 2025
43838a6
PGOV-400: removing artifacts from rebase.
Feb 10, 2025
b3a2219
PGOV-400: increase disk size on cloud.gov, image styles generator for…
Feb 11, 2025
a12b09a
PGOV-400: adding basic auth back.
Feb 11, 2025
b41a7bc
PGOV-400: Working httpd.conf.
Feb 11, 2025
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
38 changes: 38 additions & 0 deletions .bp-config/httpd/httpd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Overrides https://github.com/cloudfoundry/php-buildpack/blob/master/defaults/config/httpd/httpd.conf
# to include our customization.
# See https://docs.cloudfoundry.org/buildpacks/php/gsg-php-config.html#engine-configurations for background

ServerRoot "${HOME}/httpd"
Listen ${PORT}
ServerAdmin "${HTTPD_SERVER_ADMIN}"
ServerName "0.0.0.0"
DocumentRoot "${HOME}/#{WEBDIR}"
Include conf/extra/httpd-modules.conf
Include conf/extra/httpd-directories.conf
Include conf/extra/httpd-mime.conf
Include conf/extra/httpd-deflate.conf
Include conf/extra/httpd-logging.conf
Include conf/extra/httpd-mpm.conf
Include conf/extra/httpd-default.conf
Include conf/extra/httpd-remoteip.conf
Include conf/extra/httpd-php.conf

# If they exist, include any user-provided customizations
IncludeOptional conf/user-provided/*.conf

<IfModule !mod_headers.c>
LoadModule headers_module modules/mod_headers.so
</IfModule>

RequestHeader unset Proxy early

# Basic auth
<Directory "${HOME}/#{WEBDIR}">
AuthType Basic
AuthName "Dev site"
AuthUserFile "/home/vcap/app/apache2/.htpasswd"
<LimitExcept POST GET>
Require valid-user
Require host pgov-frontend.app.cloud.gov localhost:3000
</Limit>
</Directory>
5 changes: 5 additions & 0 deletions .bp-config/httpd/user-provided/httpd-basicauth.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Enable modules needed for http basic auth
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_user_module modules/mod_authz_user.so
2 changes: 2 additions & 0 deletions .bp-config/httpd/user-provided/httpd-drupalsupport.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Enable proxy_http for our s3fs module
LoadModule proxy_http_module modules/mod_proxy_http.so
11 changes: 11 additions & 0 deletions .bp-config/options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"COMPOSER_INSTALL_OPTIONS": [
"--no-progress --no-interaction"
],
"COMPOSER_VENDOR_DIR": "vendor",
"WEBDIR": "web",
"PHP_VERSION": "{PHP_83_LATEST}",
"ADDITIONAL_PREPROCESS_CMDS": [
"$HOME/bootstrap.sh"
]
}
8 changes: 8 additions & 0 deletions .bp-config/php/php.ini.d/extensions.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extension=apcu
extension=igbinary
extension=imagick
extension=pdo_mysql
extension=redis
extension=mysqli

zend_extension=opcache.so
3 changes: 3 additions & 0 deletions .bp-config/php/php.ini.d/memory_limit.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = 1024M
33 changes: 33 additions & 0 deletions .cfignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Ignore directories generated by Composer
/drush/contrib/
/vendor/
/web/core/
/web/modules/contrib/
/web/themes/contrib/
/web/profiles/contrib/
/web/libraries/

# Ignore node modules from USWDS or otherwise.
node_modules/

# Typically, composer generates a .gitignore to ignore the
# `settings.php` files. For cloud.gov and Cloud Foundry, no sensitive
# information is stored in the settings files. Instead, those files
# have code that parses environment variables for DB and S3
#
# Ignore sensitive information [This is a `composer` default]
# /web/sites/*/settings.php
# /web/sites/*/settings.local.php


# Ignore Drupal's file directory
/web/sites/*/files/

# Ignore SimpleTest multi-site environment.
/web/sites/simpletest

# Ignore files generated by PhpStorm
/.idea/

.DS_Store
/.ddev/
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
# Ignore files generated by PhpStorm
/.idea/

# Ignore .env and keu files as they are personal
# Ignore .env and key files as they are personal
.env
*.key

# dependencies
/node_modules
Expand All @@ -43,6 +42,8 @@ vendor
/build
/db/
/keys
*.key


# misc
.DS_Store
Expand All @@ -55,3 +56,4 @@ vendor
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.tsbuildinfo
5 changes: 5 additions & 0 deletions apt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cleancache: true
packages:
- mariadb-client
- apache2-utils
90 changes: 90 additions & 0 deletions bin/deploy-cloudgov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/sh
#
# This script will attempt to create the services required
# and then launch everything.
#

# this function will generate a random string, or bail if uuidgen is not available.
generate_string()
{
if [ -z "$1" ] ; then
if command -v uuidgen >/dev/null ; then
NEW_STRING=$(uuidgen)
export NEW_STRING
else
echo "cannot find uuidgen utility: You will need to generate some random strings and put them in the CRON_KEY, HASH_SALT, and ROOT_USER_PASS environment variables, then re-run this script."
exit 1
fi
fi
}

# If the user does not supply required data, generate some secrets.
generate_string "$CRON_KEY"
CRON_KEY=${CRON_KEY:-$NEW_STRING}

generate_string "$HASH_SALT"
HASH_SALT=${HASH_SALT:-$NEW_STRING}

generate_string "$ROOT_USER_PASS"
ROOT_USER_PASS=${ROOT_USER_PASS:-$NEW_STRING}

ROOT_USER_NAME=${ROOT_USER_NAME:-root}


# function to check if a service exists
service_exists()
{
cf service "$1" >/dev/null 2>&1
}

# create services (if needed)
if service_exists "database" ; then
echo database already created
else
if [ "$1" = "prod" ] ; then
cf create-service aws-rds medium-mysql-redundant database
else
cf create-service aws-rds small-mysql database
fi
fi

if service_exists "secrets" ; then
echo secrets already created
else
yes '' | cf create-user-provided-service secrets -p "{\"CRON_KEY\": \"$CRON_KEY\", \"HASH_SALT\": \"$HASH_SALT\", \"ROOT_USER_NAME\": \"$ROOT_USER_NAME\", \"ROOT_USER_PASS\": \"$ROOT_USER_PASS\"}"
fi

if service_exists "storage" ; then
echo storage already created
else
cf create-service s3 basic-sandbox storage
fi

# wait until the db is fully provisioned
until cf create-service-key database test-db-ok ; do
echo waiting until database is live...
sleep 20
done
cf delete-service-key database test-db-ok -f

# make the bootstrap script runnable
chmod +x ./bootstrap.sh

# launch the apps
cf push

# make sure that the app knows where it's s3fs stuff lives
cf create-service-key storage storagekey
S3INFO=$(cf service-key storage storagekey)
S3_BUCKET=$(echo "$S3INFO" | grep '"bucket":' | sed 's/.*"bucket": "\(.*\)",/\1/')
S3_REGION=$(echo "$S3INFO" | grep '"region":' | sed 's/.*"region": "\(.*\)",/\1/')
cf set-env PGOV-CMS S3_BUCKET "$S3_BUCKET"
cf set-env PGOV-CMS S3_REGION "$S3_REGION"
cf delete-service-key storage storagekey -f
cf restart PGOV-CMS

# tell people where to go
ROUTE=$(cf apps | grep PGOV-CMS | awk '{print $4}')
echo
echo
echo "To log into the drupal site, you will want to go to https://${ROUTE}/user/login and enter your username/password."
Loading