Updated the README.md
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 1m1s
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 1m1s
Added a healthcheck to the container adjusted Apache limits for memory consumption switch to microdnf for improved memory usage
This commit is contained in:
parent
e7b0bce666
commit
88f462eb04
@ -3,7 +3,7 @@ ARG PHPVER=83
|
||||
RUN dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm -y
|
||||
RUN dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
|
||||
RUN dnf update -y && dnf upgrade -y
|
||||
RUN dnf install -y httpd mod_ssl wget procps cronie iproute
|
||||
RUN dnf install -y httpd mod_ssl wget procps cronie iproute microdnf
|
||||
RUN openssl req -newkey rsa:2048 -nodes -keyout /etc/pki/tls/private/localhost.key -x509 -days 3650 -subj "/CN=localhost" -out /etc/pki/tls/certs/localhost.crt
|
||||
RUN mkdir /run/php-fpm/
|
||||
RUN mkdir /scripts
|
||||
@ -21,4 +21,6 @@ COPY ./configs/index.php /var/www/html/
|
||||
COPY ./configs/remote_ip.conf /etc/httpd/conf.d/
|
||||
RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab
|
||||
RUN yum clean all
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
||||
CMD curl -f http://localhost/ || exit 1
|
||||
ENTRYPOINT [ "/scripts/entrypoint.sh" ]
|
||||
|
136
README.md
136
README.md
@ -1,18 +1,49 @@
|
||||
# Cloud Apache Container #
|
||||
This is the base container for running PHP based applications. Select the PHP version environment variables. PHP Version Defaults to PHP 8.3
|
||||
# Cloud Apache Container
|
||||
|
||||
*__You mush have docker or compatable containerization software running.__*
|
||||
This is a base container for running PHP-based applications, supporting multiple PHP versions (7.4, 8.0, 8.1, 8.2, 8.3, 8.4). The default is PHP 8.3. The container is based on AlmaLinux 9 and uses Apache with mod_ssl. It is designed for both development and production use.
|
||||
|
||||
__You can pull this image locally by running:__
|
||||
**You must have Docker or compatible containerization software running.**
|
||||
|
||||
```console
|
||||
docker pull repo.anhonesthost.net/cloud-hosting-platform/cac:latest
|
||||
---
|
||||
|
||||
## Quick Start: Local Development with `local-dev.sh`
|
||||
|
||||
The easiest way to start a local development environment is with the provided `local-dev.sh` script. This script automates container setup, volume creation, log directories, and WordPress installation.
|
||||
|
||||
### Usage Example
|
||||
|
||||
```bash
|
||||
./local-dev.sh -n local-dev
|
||||
```
|
||||
|
||||
__You can then run a development version of the server by running the following commands:__
|
||||
*Note this is an example, you can modify the command(s) to fit your needs.*
|
||||
**Flags:**
|
||||
- `-n` Name of the container (required)
|
||||
- `-p` HTTP port (default: 80)
|
||||
- `-s` HTTPS port (default: 443)
|
||||
- `-r` Root path for files and database (default: current directory)
|
||||
- `-a` PHP version (default: 8.3; options: 74, 80, 81, 82, 83, 84)
|
||||
- `-v` Enable verbose mode
|
||||
- `-h` Show help
|
||||
|
||||
```console
|
||||
The script will:
|
||||
- Create a user directory and log folders
|
||||
- Create a Docker volume for MySQL
|
||||
- Start the container with the correct environment variables
|
||||
- Generate helper scripts in your root path:
|
||||
- `instance_start` – Start the container
|
||||
- `instance_stop` – Stop the container
|
||||
- `instance_logs` – Tail Apache logs
|
||||
- `instance_db_info` – Show MySQL credentials
|
||||
- Install WordPress in your web root
|
||||
- Print MySQL credentials
|
||||
|
||||
---
|
||||
|
||||
## Manual Docker Usage
|
||||
|
||||
You can also run the container manually:
|
||||
|
||||
```bash
|
||||
mkdir -p local-development/domain.tld
|
||||
cd local-development/domain.tld
|
||||
mkdir user
|
||||
@ -20,55 +51,72 @@ mkdir -p user/logs/{apache,system}
|
||||
docker run -d -it -p 80:80 -p 443:443 -e PHPVER=84 -e environment=DEV --mount type=bind,source="$(pwd)"/user,target=/home/myuser -v"$name-mysql":/var/lib/mysql -e uid=30001 -e user=myuser -e domain=localhost --name local-dev repo.anhonesthost.net/cloud-hosting-platform/cac:latest
|
||||
```
|
||||
|
||||
*This will start the processes needed to run sites locally.*
|
||||
---
|
||||
|
||||
The first time you start the container, it will take some time as it is installing all the required software to run the dev instance.
|
||||
## Accessing the Container
|
||||
|
||||
__If you need to get into the container you can run:__
|
||||
|
||||
```console
|
||||
```bash
|
||||
docker exec -it local-dev /bin/bash
|
||||
```
|
||||
|
||||
__To install WordPress for your site__
|
||||
---
|
||||
|
||||
```console
|
||||
cat cat /home/myuser/mysql_creds
|
||||
## WordPress Installation
|
||||
|
||||
If using `local-dev.sh`, WordPress is installed automatically. For manual setup:
|
||||
|
||||
```bash
|
||||
cat /home/myuser/mysql_creds
|
||||
su - myuser
|
||||
cd ~/public_html
|
||||
wp core download
|
||||
```
|
||||
|
||||
You should be able to then go into your browser and go to https://localhost (accept the SSL warning if it appears) and follow the prompts to setup the site.
|
||||
Then visit https://localhost (accept the SSL warning) to complete setup.
|
||||
|
||||
The database credentials are shown in the /home/```$user```/mysql_creds file, which we had *cat* in the commands above.
|
||||
---
|
||||
|
||||
### PHPVER ###
|
||||
*74* - PHP 7.4
|
||||
*80* - PHP 8.0
|
||||
*81* - PHP 8.1
|
||||
*82* - PHP 8.2
|
||||
*83* - PHP 8.3
|
||||
*84* - PHP 8.4
|
||||
## Features
|
||||
|
||||
### Environment Variables ###
|
||||
__Required Tags__
|
||||
*uid* - User ID for File Permissions
|
||||
*user* - Username for File Permissions
|
||||
*domain* - Primary Domain for configuration
|
||||
- **Multiple PHP Versions:** 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 (set with `PHPVER` or `-a` flag)
|
||||
- **Automatic Database Setup:** MariaDB is started in DEV mode, credentials are auto-generated and stored in `/home/$user/mysql_creds`.
|
||||
- **Database Backups:** Cron job backs up the database every 15 minutes to `/home/$user/_db_backups`.
|
||||
- **Log Management:** Log rotation compresses logs older than 3 days and deletes those older than 7 days.
|
||||
- **Memcached:** Started automatically in DEV mode.
|
||||
- **SSL:** Self-signed certificate enabled by default.
|
||||
- **Default Web Content:** `/home/$user/public_html` is the web root. `/ping` endpoint and `phpinfo.php` are available for diagnostics.
|
||||
- **Helper Scripts:** `instance_start`, `instance_stop`, `instance_logs`, `instance_db_info` (created by `local-dev.sh`).
|
||||
|
||||
__Optional Tags__
|
||||
*environment* - Set to DEV to start memcached and mysql locally for development purposes
|
||||
*serveralias* - Set to allow alternative hostnames for a site.
|
||||
*PHPVER* - Set to use a different version of PHP [refer to versions here.](#phpver)
|
||||
---
|
||||
|
||||
### Helpful Notes ###
|
||||
## Environment Variables
|
||||
|
||||
* A cron is set up in the container to backup the database every 15 minutes to your user's directory.
|
||||
* If you want to restart the instance again, run ```docker start {name-of-your-container}``` in the example, *name-of-your-cintainer* is *local-dev*
|
||||
* To stop a restarted instance, run ```docker stop {name-of-your-container}```
|
||||
* To view log stream from container, run ```docker logs -f {name-of-your-container}```
|
||||
* To delete a container, run ```docker rm {name-of-your-container}``` *__Note:__ this does not delete the files in user directory or database, as those are store in your system*
|
||||
* To view running containers, run ```docker ps```
|
||||
* To view all created containers, run ```docker ps --all``
|
||||
* To view all container images downloaded on your system, run ```docker images```
|
||||
**Required:**
|
||||
- `uid` – User ID for file permissions
|
||||
- `user` – Username for file permissions
|
||||
- `domain` – Primary domain for configuration
|
||||
|
||||
**Optional:**
|
||||
- `environment` – Set to `DEV` to start memcached and MySQL locally for development
|
||||
- `serveralias` – Comma-separated list of alternative hostnames
|
||||
- `PHPVER` – PHP version (see above)
|
||||
|
||||
---
|
||||
|
||||
## Helpful Notes
|
||||
|
||||
- To restart the instance: `./instance_start` or `docker start {container-name}`
|
||||
- To stop: `./instance_stop` or `docker stop {container-name}`
|
||||
- To view logs: `./instance_logs` or `docker logs -f {container-name}`
|
||||
- To get DB credentials: `./instance_db_info` or `cat /home/$user/mysql_creds`
|
||||
- To delete a container: `docker rm {container-name}` (does not delete user files or DB volume)
|
||||
- To view running containers: `docker ps`
|
||||
- To view all containers: `docker ps --all`
|
||||
- To view images: `docker images`
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
- The first run may take several minutes as dependencies are installed.
|
||||
- If you need to change PHP version, stop and remove the container, then recreate with the desired version.
|
||||
- For advanced configuration, see the scripts in the `scripts/` directory.
|
@ -7,7 +7,7 @@ Alias "/ping" "/var/www/html"
|
||||
MaxSpareThreads 75
|
||||
ThreadLimit 64
|
||||
ThreadsPerChild 25
|
||||
MaxRequestWorkers 800
|
||||
ServerLimit 32
|
||||
MaxConnectionsPerChild 1500
|
||||
MaxRequestWorkers 150
|
||||
ServerLimit 16
|
||||
MaxConnectionsPerChild 500
|
||||
</IfModule>
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "$PHPVER" ]; then
|
||||
PHPVER="81";
|
||||
PHPVER="83";
|
||||
fi
|
||||
|
||||
adduser -u $uid $user
|
||||
@ -34,7 +34,7 @@ chmod -R 755 /home/$user
|
||||
if [[ $environment == 'DEV' ]]; then
|
||||
echo "Starting Dev Deployment"
|
||||
mkdir -p /home/$user/_db_backups
|
||||
dnf install -y MariaDB-server MariaDB-client memcached
|
||||
microdnf install -y MariaDB-server MariaDB-client memcached
|
||||
nohup mysqld -umysql &
|
||||
if [ ! -f /home/$user/mysql_creds ]; then
|
||||
echo "Give MySQL a chance to finish starting..."
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
dnf module enable php:remi-7.4 -y
|
||||
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-xmlrpc \
|
||||
microdnf module enable php:remi-7.4 -y
|
||||
microdnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-xmlrpc \
|
||||
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
|
||||
php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd libzip php-cli
|
||||
exit 0
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
dnf module enable php:remi-8.0 -y
|
||||
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
microdnf module enable php:remi-8.0 -y
|
||||
microdnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
|
||||
php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd libzip php-cli
|
||||
exit 0
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
dnf module enable php:remi-8.1 -y
|
||||
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
microdnf module enable php:remi-8.1 -y
|
||||
microdnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
|
||||
php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd libzip php-cli
|
||||
exit 0
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
dnf module enable php:remi-8.2 -y
|
||||
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
microdnf module enable php:remi-8.2 -y
|
||||
microdnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
|
||||
php-mysqlnd php-mbstring php-intl php-gd libzip php-cli
|
||||
exit 0
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
dnf module enable php:remi-8.3 -y
|
||||
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
microdnf module enable php:remi-8.3 -y
|
||||
microdnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
|
||||
php-mysqlnd php-mbstring php-intl php-gd libzip php-cli
|
||||
exit 0
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
dnf module enable php:remi-8.4 -y
|
||||
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
microdnf module enable php:remi-8.4 -y
|
||||
microdnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
|
||||
php-mysqlnd php-mbstring php-intl php-gd libzip php-cli
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user