From 03b17ef004dad6539d814210c365fb044e333aee Mon Sep 17 00:00:00 2001 From: Nick Yeoman Date: Fri, 9 Jun 2023 19:04:05 -0700 Subject: [PATCH] second commit, working website --- .env | 26 ++++++++++++++ .env.staging | 26 ++++++++++++++ bin/docker_up.sh | 24 ------------- bin/inc_new_project/git_setup.sh | 18 ---------- bin/inc_new_project/remote_git_setup.sh | 32 ------------------ bin/{finalize.sh => joomla_cleanup.sh} | 0 bin/new_project.sh | 28 --------------- bin/setup_joomla_installer.sh | 45 ------------------------- docker-compose.staging.yml | 2 ++ docker-compose.yml | 3 +- 10 files changed, 55 insertions(+), 149 deletions(-) create mode 100644 .env create mode 100644 .env.staging delete mode 100644 bin/docker_up.sh delete mode 100644 bin/inc_new_project/git_setup.sh delete mode 100644 bin/inc_new_project/remote_git_setup.sh rename bin/{finalize.sh => joomla_cleanup.sh} (100%) delete mode 100644 bin/new_project.sh delete mode 100644 bin/setup_joomla_installer.sh diff --git a/.env b/.env new file mode 100644 index 0000000..a1da1b1 --- /dev/null +++ b/.env @@ -0,0 +1,26 @@ +# Docker +NETWORKNAME=admin_web + +# MySQL +MYSQL_ROOT_PASSWORD=r00tp@ssw0rd +MYSQL_USER=dbuser +MYSQL_PASSWORD=dbp@ssw0rdzztop +MYSQL_DATABASE=nydb + +# GITEA +GITEA_API_URL=https://git.nickyeoman.com/api/v1 +ACCESS_TOKEN=974f3a5e0bdc1de7bb954cb202eba196e7bb513c + +# Joomla +EMAIL=noreply@nickyeoman.com +JOOMLA_USER="Nick Yeoman" +JOOMLA_USERNAME=nick +# Passwords must be 12 characters long (admin-password) +JOOMLA_PASSWORD=RswXWgP74VKrnick + +# SMTP +SMTP_USER=null +SMTP_PASS=null +SMTP_HOST='mailhog' +SMTP_SECURITY='None' +SMTP_PORT=1025 \ No newline at end of file diff --git a/.env.staging b/.env.staging new file mode 100644 index 0000000..a1da1b1 --- /dev/null +++ b/.env.staging @@ -0,0 +1,26 @@ +# Docker +NETWORKNAME=admin_web + +# MySQL +MYSQL_ROOT_PASSWORD=r00tp@ssw0rd +MYSQL_USER=dbuser +MYSQL_PASSWORD=dbp@ssw0rdzztop +MYSQL_DATABASE=nydb + +# GITEA +GITEA_API_URL=https://git.nickyeoman.com/api/v1 +ACCESS_TOKEN=974f3a5e0bdc1de7bb954cb202eba196e7bb513c + +# Joomla +EMAIL=noreply@nickyeoman.com +JOOMLA_USER="Nick Yeoman" +JOOMLA_USERNAME=nick +# Passwords must be 12 characters long (admin-password) +JOOMLA_PASSWORD=RswXWgP74VKrnick + +# SMTP +SMTP_USER=null +SMTP_PASS=null +SMTP_HOST='mailhog' +SMTP_SECURITY='None' +SMTP_PORT=1025 \ No newline at end of file diff --git a/bin/docker_up.sh b/bin/docker_up.sh deleted file mode 100644 index d81cf83..0000000 --- a/bin/docker_up.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# Are you root? -if [ "$EUID" -ne 0 ]; then - echo -e "\033[0;31mThis script must be run as root.\033[0m" - exit 1 -fi - -# Load environment variables from .env file -set -o allexport -source .env -set +o allexport - -PROJECTNAME=$(basename "$(pwd)") - -if [ "$DEBUG" = "true" ]; then - docker ps -fi - -rm -f html/index.html - -docker-compose up -d - -docker-compose ps \ No newline at end of file diff --git a/bin/inc_new_project/git_setup.sh b/bin/inc_new_project/git_setup.sh deleted file mode 100644 index 99b4559..0000000 --- a/bin/inc_new_project/git_setup.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -PROJECTNAME=$(basename "$(pwd)") - -# Remove existing Git repository information -rm -rf .git - -rm README.md -touch README.md -echo "# ${PROJECTNAME}" > README.md -echo "" > README.md -echo "Created a fresh repo for your ${PROJECTNAME} project." >> README.md - -# Initialize a new Git repository -echo -e "\n\e[32mSetup Git Locally\e[0m\n"; -git init -git add . -git commit -m "Initial commit of new project $PROJECTNAME" diff --git a/bin/inc_new_project/remote_git_setup.sh b/bin/inc_new_project/remote_git_setup.sh deleted file mode 100644 index 4eaaecd..0000000 --- a/bin/inc_new_project/remote_git_setup.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -PROJECTNAME=$(basename "$(pwd)") - -echo -e "\n\e[32mSetup Git Remotely\e[0m\n"; - -DESC="Repo auto created by Joomla remote git script creator for $PROJECTNAME" - -# Create the repository using Gitea API -RESPONSE=$(curl -s -X POST \ - -H "Authorization: token $ACCESS_TOKEN" \ - -H "Content-Type: application/json" \ - -d "{\"name\":\"$PROJECTNAME\",\"private\": true,\"description\": \"$DESC\"}" \ - $GITEA_API_URL/user/repos) - -if [ -z "$RESPONSE" ] || [ "$(echo "$RESPONSE" | jq -r '.id')" = "null" ]; then - echo "Error: Failed to create $PROJECTNAME repository." - exit 1 -fi - -SSH_URL=$(echo "$RESPONSE" | jq -r '.ssh_url') -if [ "$SSH_URL" = "null" ]; then - echo "Error: Failed to retrieve SSH URL for $PROJECTNAME repository." - exit 1 -fi - -# Add new remote repository -git remote add origin "$SSH_URL" -git remote -v - -# Commit existing changes -git push -u origin master \ No newline at end of file diff --git a/bin/finalize.sh b/bin/joomla_cleanup.sh similarity index 100% rename from bin/finalize.sh rename to bin/joomla_cleanup.sh diff --git a/bin/new_project.sh b/bin/new_project.sh deleted file mode 100644 index 8ec346a..0000000 --- a/bin/new_project.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -PROJECTNAME=$(basename "$(pwd)") -SETGITEA=true - -# Verify the .env file exists -if [ ! -f ".env" ]; then - echo "Error: The .env file does not exist." - exit 1 -fi - -# Load environment variables from .env file -set -o allexport -source .env -set +o allexport - -# Run Git setup -bash bin/inc_new_project/git_setup.sh - -if [ "$GITEA_API_URL" = "REPLACEME" ]; then - SETGITEA=false -fi - -# Run remote Git setup -if [ "$SETGITEA" = "true" ]; then - bash bin/inc_new_project/remote_git_setup.sh -fi -echo -e "\e[32mAll Done\e[0m"; \ No newline at end of file diff --git a/bin/setup_joomla_installer.sh b/bin/setup_joomla_installer.sh deleted file mode 100644 index 1957e95..0000000 --- a/bin/setup_joomla_installer.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -PROJECTNAME=$(basename "$(pwd)") - -# Are you root? -if [ "$EUID" -ne 0 ]; then - echo -e "\033[0;31mThis script must be run as root.\033[0m" - exit 1 -fi - -################################################################## -# ENV file -################################################################## -# Verify the .env file exists -if [ ! -f ".env" ]; then - echo "Error: The .env file does not exist." - exit 1 -fi - -# Load environment variables from .env file -set -o allexport -source .env -set +o allexport - -################################################################## -# non interactive install -# -# https://docs.joomla.org/J4.x:Joomla_CLI_Installation -################################################################## - -DB_PREFIX=$(LC_CTYPE=C tr -dc '[:alpha:]' < /dev/urandom | head -c 3)_ - -docker-compose exec -u www-data joomla php installation/joomla.php install \ - --site-name=$PROJECTNAME \ - --admin-email=$EMAIL \ - --admin-user="$JOOMLA_USER" \ - --admin-username=$JOOMLA_USERNAME \ - --admin-password=$JOOMLA_PASSWORD \ - --db-type=mysqli \ - --db-host=mariadb-joomla \ - --db-user=$MYSQL_USER \ - --db-pass=$MYSQL_PASSWORD \ - --db-name=$MYSQL_DATABASE \ - --db-prefix=$DB_PREFIX \ - --db-encryption=0 diff --git a/docker-compose.staging.yml b/docker-compose.staging.yml index 1e7a80c..caa3968 100644 --- a/docker-compose.staging.yml +++ b/docker-compose.staging.yml @@ -2,6 +2,8 @@ version: '3.8' services: joomla: + volumes: + - ./development:/development ports: - "8000:80" diff --git a/docker-compose.yml b/docker-compose.yml index d2d5d31..2f299c3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,8 +40,7 @@ services: JOOMLA_DB_PASSWORD: ${MYSQL_PASSWORD} JOOMLA_DB_NAME: ${MYSQL_DATABASE} volumes: - - ./html:/var/www/html - - ./development:/development + - joomla:/var/www/html - ./php/php.ini:/usr/local/etc/php/php.ini - "/etc/timezone:/etc/timezone:ro" - "/etc/localtime:/etc/localtime:ro"