-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from trants/main
Initial dockerizing application, Updated images config files & secret key environment
- Loading branch information
Showing
35 changed files
with
509 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Nginx | ||
NGINX_PORT= | ||
NGINX_HTTPS_PORT= | ||
|
||
# PHP | ||
BLACKFIRE_CLIENT_ID= | ||
BLACKFIRE_CLIENT_TOKEN= | ||
COMPOSER_DISABLE_XDEBUG_WARN=1 | ||
PHP_CS_FIXER_IGNORE_ENV=1 | ||
|
||
# MariaDB | ||
MARIA_DB_PORT=3306 | ||
MYSQL_ROOT_PASSWORD=root | ||
|
||
# PostgreSQL | ||
POSTGRES_DB_PORT=5432 | ||
POSTGRES_USER=root | ||
POSTGRES_PASSWORD=root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,3 +74,7 @@ Temporary Items | |
|
||
# Environment's params | ||
.env | ||
|
||
# Directories docker | ||
docker/nginx/sites-enabled/*.conf | ||
compose/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,105 @@ | ||
# Flash Development | ||
|
||
This repository allows you to quickly get a development environment up and running using Docker, including a MySQL, | ||
PostgreSQL | ||
database and some debugging tools. | ||
|
||
This environment includes the latest versions of the following software: | ||
|
||
- `nginx` | ||
- `phpfpm` | ||
- `mariadb` | ||
- `postgresql` | ||
- `xdebug` | ||
|
||
### 📦 Requirements | ||
|
||
The Docker & Docker Compose system requirements are Linux Ubuntu as the OS (other operating systems are supported as | ||
well), an absolute minimum 512MB RAM (2GB recommended) | ||
|
||
In order to install docker Ubuntu, you will need to meet the following requirements: | ||
|
||
- OS: Linux Ubuntu | ||
- Memory: 512MB RAM (2GB Recommended) | ||
- Disk: Sufficient amount to run the Docker containers you wish to use | ||
- CPU: Dependant on the applications you wish to run in the containers | ||
|
||
### 📋 Features | ||
|
||
- Easy switch between PHP versions: 8.3, 8.2, 8.1, 8.0 7.4, 7.3, 7.2, 7.1, 5.6… | ||
- Choose your favorite database engine: MySQL, Postgres, MariaDB… | ||
- Run your own stack: Memcached, HHVM, RabbitMQ… | ||
- Each software runs on its own container: PHP-FPM, NGINX, PHP-CLI… | ||
- Easy to customize any container, with simple edit to the Dockerfile. | ||
- All Images extend from an official base Image. (Trusted base Images). | ||
- Pre-configured NGINX to host any code at your root directory. | ||
- Can use per project,or single for all projects. | ||
- Easy to install/remove software’s in Containers using environment variables. | ||
- Clean and well-structured Dockerfiles (Dockerfile). | ||
- Latest version of the Docker Compose file (docker-compose). | ||
- Everything is visible and editable. | ||
- Fast Images Builds. | ||
|
||
### 🔧 Installation | ||
|
||
1. Install Docker and Docker-Compose | ||
|
||
- [Docker Install documentation](https://docs.docker.com/install/) | ||
- [Docker-Compose Install documentation](https://docs.docker.com/compose/install/) | ||
|
||
2. Bring up your stack by running | ||
|
||
```shell | ||
git clone https://github.com/hitechnix/flash-development.git \ | ||
&& cd flash-development \ | ||
&& cp .env.example .env | ||
``` | ||
|
||
3. Edit environment variable | ||
|
||
```bash | ||
# Nginx | ||
NGINX_PORT= | ||
NGINX_HTTPS_PORT= | ||
|
||
# PHP | ||
BLACKFIRE_CLIENT_ID= | ||
BLACKFIRE_CLIENT_TOKEN= | ||
COMPOSER_DISABLE_XDEBUG_WARN=1 | ||
PHP_CS_FIXER_IGNORE_ENV=1 | ||
|
||
# MariaDB | ||
MARIA_DB_PORT=3306 | ||
MYSQL_ROOT_PASSWORD=root | ||
|
||
# PostgreSQL | ||
POSTGRES_DB_PORT=5432 | ||
POSTGRES_USER=root | ||
POSTGRES_PASSWORD=root | ||
``` | ||
|
||
4. Start application | ||
|
||
```shell | ||
docker-compose up -d | ||
``` | ||
|
||
### 📝 Usage | ||
|
||
Reader-friendly documentation can be found [here][link-docs]. | ||
|
||
### 📨 Message | ||
|
||
I hope you find this useful. If you have any questions, please create an issue. | ||
|
||
### 🔐 Security | ||
|
||
If you discover any security related issues, please email support@hitechnix.com instead of using the issue tracker. | ||
|
||
### 📖 License | ||
|
||
This software is released under the [BSD 3-Clause][link-license] License. Please see the [LICENSE](LICENSE) file | ||
or https://opensource.hitechnix.com/LICENSE.txt for more information. | ||
|
||
[link-docs]:https://opensource.hitechnix.com/flash-development | ||
[link-license]: https://opensource.org/license/bsd-3-clause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
bin/cli bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
[ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit | ||
docker-compose exec php "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
[ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit | ||
# -T: Disable pseudo-tty allocation | ||
docker-compose exec -T php "$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
[ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit | ||
# Without stdout and stderr | ||
bin/clinotty "$@" >/dev/null 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
bin/cli composer "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
[ -z "$1" ] && echo "Please specify a directory or file to copy from container (ex. vendor, --all)" && exit | ||
|
||
REAL_SRC=$(cd -P "src" && pwd) | ||
if [ "$1" == "--all" ]; then | ||
docker cp "$(bin/docker-compose ps -q php|awk '{print $1}')":/var/www/./ "$REAL_SRC/" | ||
echo "Completed copying all files from container to host" | ||
else | ||
if [ -f "$1" ] ; then | ||
docker cp "$(bin/docker-compose ps -q php|awk '{print $1}')":/var/www/"$1" "$REAL_SRC/$1" | ||
else | ||
docker cp "$(bin/docker-compose ps -q php|awk '{print $1}')":/var/www/"$1" "$REAL_SRC/$(dirname "$1")" | ||
fi | ||
echo "Completed copying $1 from container to host" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
[ -z "$1" ] && echo "Please specify a directory or file to copy to container (ex. vendor, --all)" && exit | ||
|
||
REAL_SRC=$(cd -P "src" && pwd) | ||
if [ "$1" == "--all" ]; then | ||
docker cp "$REAL_SRC/./" "$(bin/docker-compose ps -q php|awk '{print $1}')":/var/www/ | ||
echo "Completed copying all files from host to container" | ||
bin/fixowns | ||
bin/fixperms | ||
else | ||
if [ -f "$REAL_SRC/$1" ]; then | ||
docker cp "$REAL_SRC/${1}" "$(bin/docker-compose ps -q php|awk '{print $1}')":/var/www/"$1" | ||
else | ||
docker cp "$REAL_SRC/${1}" "$(bin/docker-compose ps -q php|awk '{print $1}')":/var/www/"$(dirname "$1")" | ||
fi | ||
echo "Completed copying $1 from host to container" | ||
bin/fixowns "$1" | ||
bin/fixperms "$1" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
bin/cli node "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
bin/cli npm "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
docker-compose -f docker-compose.yml rm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
bin/remove | ||
bin/removevolumes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
current_folder=${PWD##*/} | ||
volume_prefix=$(echo "$current_folder" | awk '{print tolower($0)}' | sed 's/\.//g') | ||
docker volume rm "${volume_prefix}"_mariadb-data | ||
docker volume rm "${volume_prefix}"_postgresql-data | ||
docker volume rm "${volume_prefix}"_sockdata | ||
docker volume rm "${volume_prefix}"_ssldata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
bin/stop | ||
bin/start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
[ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit | ||
docker-compose exec -u root php "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
[ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit | ||
docker-compose exec -u root -T php "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
|
||
[ -z "$1" ] && echo "Please specify a domain name (ex. domain.test)" && exit | ||
|
||
DOMAIN=$1 | ||
|
||
echo "Your system password has been requested to add an entry to /etc/hosts..." | ||
echo "127.0.0.1 ::1 $DOMAIN" | sudo tee -a /etc/hosts | ||
|
||
echo "Generating SSL certificate..." | ||
bin/setup-ssl "$DOMAIN" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
[ -z "$1" ] && echo "Please specify a domain (ex. domain.test)" && exit | ||
|
||
# Generate certificate authority if not already setup | ||
if ! docker-compose exec -T -u root nginx cat /root/.local/share/mkcert/rootCA.pem | grep -q 'BEGIN CERTIFICATE'; then | ||
bin/setup-ssl-ca | ||
fi | ||
|
||
# Generate the certificate for the specified domain | ||
docker-compose exec -T -u root nginx mkcert -key-file nginx.key -cert-file nginx.crt "$@" | ||
echo "Moving key and cert to /etc/nginx/certs/..." | ||
docker-compose exec -T -u root nginx chown app:app nginx.key nginx.crt | ||
docker-compose exec -T -u root nginx mv nginx.key nginx.crt /etc/nginx/certs/ | ||
|
||
# Restart nginx to apply the updates | ||
echo "Restarting containers to apply updates..." | ||
bin/restart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
# Generate a new local CA "/root/.local/share/mkcert" | ||
docker-compose exec -T -u root nginx mkcert -install | ||
|
||
docker cp "$(docker-compose ps -q nginx|awk '{print $1}')":/root/.local/share/mkcert/rootCA.pem . | ||
echo "System password requested to install certificate authority on host..." | ||
|
||
if [ "$(uname)" == "Darwin" ]; then | ||
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain rootCA.pem | ||
|
||
### Check if Firefox is installed | ||
FFoxBin="/Applications/Firefox.app/Contents/MacOS/firefox-bin" | ||
if [ -f "$FFoxBin" ]; then | ||
echo "{\"policies\": {\"Certificates\": {\"ImportEnterpriseRoots\": true}}}" | sudo tee policies.json | ||
|
||
### Check if distribution directory exists | ||
DistDirectory="/Applications/Firefox.app/Contents/Resources/distribution" | ||
if [ ! -d "$DistDirectory" ]; then | ||
sudo mkdir "$DistDirectory" | ||
fi | ||
### Move the newly created policies.json to the Certificates directory | ||
sudo mv policies.json "$DistDirectory"/policies.json | ||
|
||
### Check if Certificates directory exists | ||
CertDirectory="/Library/Application Support/Mozilla/Certificates" | ||
if [ ! -d "$CertDirectory" ]; then | ||
sudo mkdir "$CertDirectory" | ||
fi | ||
|
||
### Move the newly created .pem to the Certificates directory | ||
sudo mv rootCA.pem "$CertDirectory"/rootCA.pem | ||
else | ||
sudo rm rootCA.pem | ||
fi | ||
|
||
else | ||
|
||
### Requirement: apt install libnss3-tools | ||
REQUIRED_PKG="libnss3-tools" | ||
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed") | ||
echo Checking for $REQUIRED_PKG: "$PKG_OK" | ||
if [ "" = "$PKG_OK" ]; then | ||
echo "No $REQUIRED_PKG found. Setting up $REQUIRED_PKG." | ||
sudo apt-get --yes install $REQUIRED_PKG | ||
fi | ||
|
||
### CA file to install (CUSTOMIZE!) | ||
certfile="rootCA.pem" | ||
certname="Root CA" | ||
|
||
### For cert8 (legacy - DBM) | ||
find ~/ -name "cert8.db" -print0 | while read -r certDB | ||
do | ||
certdir=$(dirname "${certDB}"); | ||
certutil -D -n "${certname}" -i ${certfile} -d dbm:"${certdir}" | ||
certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d dbm:"${certdir}" | ||
done | ||
|
||
### For cert9 (SQL) | ||
find ~/ -name "cert9.db" -print0 | while read -r certDB | ||
do | ||
certdir=$(dirname "${certDB}"); | ||
certutil -D -n "${certname}" -i ${certfile} -d sql:"${certdir}" | ||
certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d sql:"${certdir}" | ||
done | ||
|
||
sudo mv rootCA.pem /usr/local/share/ca-certificates/rootCA.crt | ||
sudo update-ca-certificates | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
docker-compose -f docker-compose.yml start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
docker-compose -f docker-compose.yml ps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
docker-compose -f docker-compose.yml stop |
Oops, something went wrong.