https://github.com/b23prodtm/acake2php
The Docker web-server features well-known functionalities as cool as posting some web contents with pictures stored in a database. Submodules may be installed via Composer packages.
https://github.com/b23prodtm/acake2php
apache cakephp circleci cms docker-image mariadb mysql openshift php-framework
Last synced: 11 days ago
JSON representation
The Docker web-server features well-known functionalities as cool as posting some web contents with pictures stored in a database. Submodules may be installed via Composer packages.
- Host: GitHub
- URL: https://github.com/b23prodtm/acake2php
- Owner: b23prodtm
- License: apache-2.0
- Created: 2017-09-02T11:11:08.000Z (about 8 years ago)
- Default Branch: development
- Last Pushed: 2025-02-03T16:56:42.000Z (9 months ago)
- Last Synced: 2025-02-03T17:40:56.721Z (9 months ago)
- Topics: apache, cakephp, circleci, cms, docker-image, mariadb, mysql, openshift, php-framework
- Language: PHP
- Homepage: http://www.b23prodtm.info
- Size: 5.41 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
- [A Cake2PHP website](#a-cake2php-3.x-application)
+ [Quickstart](#quickstart)
- [Plugins](#plugins)
+ [NodeJs packages](#nodejs-packages)
+ [Composer Plugins](#composer-plugins)
+ [Local Built-in Server](#local-built-in-server)
+ [PHPUnit Test](#phpunit-test)
+ [Device pod environment](#device-pod-environment)
- [Database terminal](#database-terminal)
+ [More Database Configuration](#more-database-configuration)
+ [Generate new administrator password](#generate-new-administrator-password)
+ [Common Issues](FAQ.md#common-issues)
+ [Cross Platform](#cross-platform)
+ [Docker Hub](#docker-hub)
+ [License](#license)
A Cake2PHP website
==================
[](https://travis-ci.com/b23prodtm/acake2php)
[](https://app.circleci.com/pipelines/github/b23prodtm/acake2php)
> [The PHP-CMS eShop project was at the origin of this application](https://sourceforge.net/projects/pohse/)
Quickstart
----------
Using the basic container orchestrator or engine to deploy and test, is straitforward.
Currently the deployment script
```. deploy.sh```
Based on [Balena engine](http://www.balena.io). See more about [NodeJs dependencies](#nodejs-dependencies)
[](https://dashboard.balena-cloud.com/deploy?repoUrl=https://github.com/b23prodtm/acake2php)
Requirements
------------
To deploy a server or onto a container manager like docker, you need at least a developer environment with the following software:
+ PHP 7.4 or later in PATH
+ NodeJS 19 or later in PATH and NPM or Yarn (recommended in Windows)
+ Package managers NPM or Yarn, also HomeBrew, MacPorts or Chocolatey, etc.
+ a Docker setup (Mac or PC) or BalenaEngine (Linux)
+ (recommended for Windows) git unix-style shell, like Git Bash
+ OpenSSH Agent with key-pair (.ssh/*.pub) must be added to the webserver host
Configuration
-------------
Once you have got the server up and running (usually in a docker container), the website may not be reacheable until the database is configured.
You need to have network access to the host running the webservice as a container, just connect to it, with BalenaOS it's very easy:
./balena-connect-it.sh 22222 acake2php
Otherwise use:
ssh -ttp docker exec -it "/bin/sh"
Once you're logged in, run as a normal user in `/var/www/localhost/htdocs #` :
./configure.sh -d -i -u
It will configure PHP plugins and migrate the table in databases.
You can also test the configuration, lauch Cake Tests from `/var/www/localhost/htdocs #` :
./test-cake.sh
Plugins
-------
You do not need to change anything in your existing PHP project's repository.
However, if these files exist they will affect the behavior of the build process:
* Packagist **composer.json**
Update all required plugins
composer update
[Packagist](https://packagist.org).
#### Node modules
* **package.json**
List of dependencies to be installed with `npmjs` [here](https://www.npmjs.com).
yarn
Install the balenaCloud helper package [balena-cloud-apps](https://www.npmjs.com/package/balena-cloud-apps).
sudo npm link balena-cloud-apps
whenever the system complains about `balena_deploy` not found.
* **Templates files**
Setup environment variables, build files, ready for deployment with any of the available targets:
Scripts/update-templates.sh
#### Composer Plugins
Plugins are registered in both _git submodule_ and _composer.json_. To make them ready for build, edit _composer.json_ as needed and launch the command ```composer update```.
Plugins home folder:
app/Vendor/
app/Plugin//
* **.htaccess**
To allow Apache server to browse directly to the app/webroot folder on server-side, use mod_rewrite rules, as provided by .htaccess files.
>/.htaccess
RewriteEngine on
# Uncomment if you have a .well-known directory in the root folder, e.g. for the Let's Encrypt challenge
# https://tools.ietf.org/html/rfc5785
#RewriteRule ^(\.well-known/.*)$ $1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
>/app/.htaccess
RewriteEngine on
RewriteBase /app/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
Local Built-in Server
---------------------
* CakePHP application also supports Docker
* MariaDB 10.1 and later
Start a local server machine for testing on port 9000.
Open a Terminal window:
DB=Mysql ./configure.sh --mig-database -u
./start-cake.sh --docker -c server -p 9000
> Ctrl-click the URL that appear on the terminal. It will open them in the browser. To get more help about the command line interface :
./start-cake.sh --help
### PHPUnit Test
JUNIT tests are available with the following call to CAKE server:
Open a Terminal window:
./test-cake.sh
There are options (--runner, --travis) dedicated to continuous integration build environments. Use --help to see more about options.
See [below](#common-issues) to allow access on the built-in local server.
Device pod environment
----------------------
When deployment happens on device or is triggered by a git push event, 'source-to-image (s2i)', the httpd-server or pod needs proper environment variables to be set ready. Otherwise the scripts will fail with an error state, unable to connect to the database
The following variables must be set up as server environment, provided by your **database administrator**:
# Sqlite, Postgres
DB:Mysql
> Note: DB selects CakePhp Model/Datasource/Database DBOSource class to configure SQL connections.
MYSQL_DATABASE:default
# a hostname or IP address
MYSQL_HOST:mysql
> Note: Prefixed with *TEST_* they are used by the index.php?test=1 URLs and ./test-cake.sh (--travis)
The following additional variables must be set up as server secrets environment, provided by your database administrator:
#(optional)
WEBHOOK_URL:
# Persistent connection credentials
DATABASE_USER:
MYSQL_ROOT_PASSWORD:
# Just add MYSQL_USER and MYSQL_PASSWORD
MYSQL_USER:
MYSQL_PASSWORD:
# CakePHP generated
CAKEPHP_SECRET_TOKEN:
CAKEPHP_SECRET_SALT:
CAKEPHP_SECURITY_CIPHER_SEED:
# Generated by ./configure.sh -h
GET_HASH_PASSWORD:
MYSQL_DATABASE
aria_db
MYSQL_HOST
db
MYSQL_PASSWORD
maria-abc
MYSQL_ROOT_PASSWORD
mariadb
MYSQL_TCP_PORT
3306
MYSQL_USER
maria
SERVER_NAME
#### **db** pod healthcheck
Container engines provides a sanbox virtual system with some persistent storage. To check that the last database migration was successful, open a pod shell :
mysql -uroot --password=${MYSQL_ROOT_PASSWORD}
Issue some SQL statements, for instance :
use aria_db; show tables;
To temporarily change the MYSQL_ROOT_PASSWORD in a pod:
mysql_secure_installation
This should list all the migrated tables
#### **acake2php** pod healthcheck
cake schema update --connection=default
This should migrate the databases.
cake schema update --connection=test
This should migrate the test databases.
#### Database
By editing the files `Config/app_local.template` and `Config/Schema/AppSchema.template` if you wish to modify the database connection and email transport.
You can then configure and migrate databases (configuration and migration)
./configure.sh -d -i -u
More about configuration:
./configure.sh --help && ./migrate-database.sh --help
More [common issues](#common-issues)
#### Generate new administrator password
To sign in with staff rights, at http://localhost/admin/index.php, somebody needs a unique password stored in `GET_HASH_PASSWORD`. One way to generate this hashed password with "hashed“ encryption and setup:
./configure.sh -p -s
To regenerate or read the current password hash again, simply browse to http://localhost/php-cms/e13/etc/getHashPassword.php
HASH_PASSWORD=
or:
GET_HASH_PASSWORD=
One of them must be stored in the local server environment as a system readable variable.
Cross Platform
--------------
If selecting an ARM device target from an ordinary X86 machine, first enable the RUN [ cross-build-start ] and RUN [ cross-build-end ] balenaOS cross-platform build modes, run `./deploy.sh`:
1:local-balena
Choose the target architecture, and then choose the option:
6:build dependencies
Only balenaOS baselib images can use cross-build based on balenaEngine. You should otherwise run `docker buildx build --platform=linux/arm64` from an ARM computer.
BalenaOS and BalenaCloud as an open source platform allow us to maintain a small devices fleet (aka swarm, cluster).
Use Balena one button deployment, update the source code as your needs, and deploy to BalenaCloud, this will disable cross-platform build:
2:balena
5:push
You are able to deploy to a balena fleet, using their original deployment process.
Docker Hub
----------
You should configure a DOCKER_USER and DOCKER_PASS as environment variables. You may use an [access_token](https://docs.docker.com/security/for-developers/access-tokens/#use-an-access-token) for DOCKER_PASS for better security.
License
-------
Copyright 2016-2025 www.b23prodtm.info
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.