Enable docker config override (#3908)

This commit is contained in:
jekkos
2023-12-23 01:46:54 +01:00
committed by jekkos
parent 60c3a9a96f
commit 8dbb8f8f69
9 changed files with 43 additions and 162 deletions

View File

@@ -45,6 +45,17 @@ I've added the following Powershell scripts to make my life a bit easier, which
* `build.ps1` - Which runs the build but also restores the .env from a backup I make of it in a specifically placed folder. I place a copy of the configured .env file in a folder that has the following path from the working folder: `../env/<working-folder-name>/.env`
### Containerized setup
Development using docker has the advantage that all the application's dependencies are contained within the docker environment. During development we want to have a live version of the code in the container when we edit it. This is accomplished by mounting the application folder within the /app of the docker container.
The file permissions for the repository in the container should be the same as on the host. That's why we have to startthe PHP process in docker with the host current uid.
```
export UID=$(id -u)
export GID=$(id -g)
docker-compose -f docker-compose.dev.yml up
```
## The Result
The build creates a developer version of a runnable instance of OSPOS. It contains a ton of developer stuff that **should not be deployed to a production environment**.

View File

@@ -21,7 +21,6 @@ CMD ["/app/vendor/phpunit/phpunit/phpunit"]
FROM ospos AS ospos_dev
RUN mkdir -p /app/bower_components && ln -s /app/bower_components /var/www/html/bower_components
RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini \

View File

@@ -76,6 +76,9 @@ class Database extends Config
*
* @var array
*/
public $development = [
'DSN' => '',
'hostname' => 'localhost',
@@ -102,21 +105,6 @@ class Database extends Config
{
parent::__construct();
if(!getenv('database.development.hostname'))
{
$this->development['hostname'] = getenv('database.development.hostname');
}
if(!getenv('database.development.hostname'))
{
$this->development['username'] = getenv('database.development.username');
}
if(!getenv('database.development.hostname'))
{
$this->development['password'] = getenv('database.development.password');
}
// Ensure that we always set the database group to 'tests' if
// we are currently running an automated test suite, so that
// we don't overwrite live data on accident.
@@ -129,5 +117,14 @@ class Database extends Config
$this->defaultGroup = 'development';
break;
}
foreach ([&$this->development, &$this->tests, &$this->default] as &$config) {
$config['hostname'] = !getenv('MYSQL_HOST_NAME') ? $config['hostname'] : getenv('MYSQL_HOST_NAME');
$config['username'] = !getenv('MYSQL_USERNAME') ? $config['username'] : getenv('MYSQL_USERNAME');
$config['password'] = !getenv('MYSQL_PASSWORD') ? $config['password'] : getenv('MYSQL_PASSWORD');
$config['database'] = !getenv('MYSQL_DB_NAME') ? $config['database'] : getenv('MYSQL_DB_NAME');
}
}
}

View File

@@ -1,17 +1,7 @@
version: '2'
volumes:
uploads:
driver: local
logs:
driver: local
mysql:
driver: local
networks:
app_net:
db_net:
version: '3.4'
include:
- docker/docker-mysql.yml
services:
ospos:
build:
@@ -26,33 +16,13 @@ services:
- "80:80"
networks:
- app_net
- db_net
volumes:
- .:/app
- uploads:/app/public/uploads
- logs:/app/application/logs
environment:
- PHP_TIMEZONE=UTC
- CI_ENVIRONMENT=development
- MYSQL_USERNAME=admin
- MYSQL_PASSWORD=pointofsale
- MYSQL_DB_NAME=ospos
- MYSQL_HOST_NAME=mysql
- XDEBUG_CONFIG=remote_host=172.17.0.1
mysql:
image: mariadb:10.5
container_name: mysql
restart: always
expose:
- "3306"
networks:
- db_net
volumes:
- ./app/Database:/docker-entrypoint-initdb.d
- mysql:/var/lib/mysql:rw
environment:
- MYSQL_ROOT_PASSWORD=pointofsale
- MYSQL_DATABASE=ospos
- MYSQL_USER=admin
- MYSQL_PASSWORD=pointofsale
- PHP_TIMEZONE=UTC
- XDEBUG_CONFIG=client_host=172.17.0.1

View File

@@ -1,4 +1,4 @@
version: '3.4'
version: '2.2'
volumes:
uploads:
@@ -22,12 +22,11 @@ services:
- "80"
networks:
- app_net
- db_net
volumes:
- uploads:/app/public/uploads
- logs:/app/application/logs
environment:
- CI_ENV=${OSPOS_CI_ENV}
- CI_ENVIRONMENT=${OSPOS_CI_ENV}
- FORCE_HTTPS=true
- PHP_TIMEZONE=UTC
- MYSQL_USERNAME=${OSPOS_MYSQL_USERNAME}
@@ -62,7 +61,6 @@ services:
- "80"
networks:
- app_net
- db_net
environment:
- MYSQL_USERNAME=${OSPOS_MYSQL_USERNAME}
- MYSQL_ROOT_PASSWORD=${OSPOS_MYSQL_ROOT_PASSWORD}

View File

@@ -1,60 +1,9 @@
version: '3.4'
version: '2.2'
volumes:
uploads:
driver: local
logs:
driver: local
mysql:
driver: local
networks:
app_net:
db_net:
include:
- docker-compose.dev.yml
services:
ospos:
build:
context: .
target: ospos_dev
container_name: ospos_dev
restart: always
depends_on:
- mysql
ports:
- "80:80"
networks:
- app_net
- db_net
volumes:
- .:/app
- uploads:/app/public/uploads
- logs:/app/application/logs
environment:
- PHP_TIMEZONE=UTC
- MYSQL_USERNAME=admin
- MYSQL_PASSWORD=pointofsale
- MYSQL_DB_NAME=ospos
- MYSQL_HOST_NAME=mysql
- XDEBUG_CONFIG=remote_host=172.17.0.1
mysql:
image: mariadb:10.5
container_name: mysql
restart: always
expose:
- "3306"
networks:
- db_net
volumes:
- ./database/database.sql:/docker-entrypoint-initdb.d/database.sql
- mysql:/var/lib/mysql:rw
environment:
- MYSQL_ROOT_PASSWORD=pointofsale
- MYSQL_DATABASE=ospos
- MYSQL_USER=admin
- MYSQL_PASSWORD=pointofsale
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
@@ -65,8 +14,7 @@ services:
- "8000:80"
networks:
- app_net
- db_net
environment:
- MYSQL_USERNAME=admin
- MYSQL_ROOT_PASSWORD=pointofsale
- PMA_HOST=mysql
- PMA_HOST=mysql

View File

@@ -1,5 +1,8 @@
version: '3.4'
version: '2.2'
include:
- docker/docker-mysql.yaml
services:
test:
build:
@@ -9,7 +12,7 @@ services:
- mysql
container_name: ospos_test
environment:
- CI_ENV=testing
- CI_ENVIRONMENT=testing
- ENCRYPTION_KEY=
- MYSQL_HOST_NAME=mysql
- MYSQL_DATABASE=ospos
@@ -19,14 +22,3 @@ services:
ports:
- "80:80"
mysql:
image: mariadb:10.5
container_name: mysql
restart: always
volumes:
- ./database/database.sql:/docker-entrypoint-initdb.d/database.sql
environment:
- MYSQL_ROOT_PASSWORD=pointofsale
- MYSQL_DATABASE=ospos
- MYSQL_USER=admin
- MYSQL_PASSWORD=pointofsale

View File

@@ -1,23 +1,14 @@
version: '2'
volumes:
uploads:
driver: local
logs:
driver: local
mysql:
driver: local
networks:
app_net:
db_net:
include:
- docker/docker-mysql.yml
services:
sqlscript:
image: jekkos/opensourcepos:sql-ci4
image: jekkos/opensourcepos:sql-ci4-branch
command: /bin/sh -c 'exit 0'
ospos:
image: jekkos/opensourcepos:ci4-upgrade
image: jekkos/opensourcepos:ci4-branch
restart: always
depends_on:
- mysql
@@ -25,7 +16,6 @@ services:
- "127.0.0.1:80:80"
networks:
- app_net
- db_net
volumes:
- uploads:/app/public/uploads
- logs:/app/application/logs
@@ -38,21 +28,3 @@ services:
- MYSQL_DB_NAME=ospos
- MYSQL_HOST_NAME=mysql
mysql:
image: mariadb:10.5
container_name: mysql
restart: always
expose:
- "3306"
networks:
- db_net
volumes_from:
- sqlscript
volumes:
- mysql:/var/lib/mysql:rw
environment:
- MYSQL_ROOT_PASSWORD=pointofsale
- MYSQL_DATABASE=ospos
- MYSQL_USER=admin
- MYSQL_PASSWORD=pointofsale

View File

@@ -1,6 +0,0 @@
#!/bin/bash
docker run --rm -v $(pwd):/app jekkos/composer composer install
docker run --rm -v $(pwd):/app jekkos/composer php bin/install.php translations develop
sed -i "s/'\(dev\)'/'$rev'/g" application/config/config.php
docker run --rm -it -v $(pwd):/app -w /app digitallyseamless/nodejs-bower-grunt sh -c "npm install && bower install && grunt package"