An educational Phalcon application divided into 2 parts:
client
(web app)server
(REST API)
docker >= 1.10.0
docker-compose >= 1.6.0
On Windows, the project must be under C:\Users
, eg C:\Users\abc\PhpstormProjects\SAM
git clone https://github.com/beni92/SAM
cd SAM
docker-compose up -d
docker-compose stop
docker-compose rm
# code
git pull
# containers
docker-compose pull
docker-compose up -d
docker ps
docker-compose ps
docker logs <container id>
docker-compose logs <service name>
# exited containers
docker rm -v $(docker ps -f "status=exited" -q -a)
# unused images
docker rmi $(docker images -f "dangling=true" -q)
# unused volumes
docker volume rm $(docker volume ls -f "dangling=true" -q)
# mysql
<docker machine ip>:13306
# client
http://<docker machine ip>:1080
# server
http://<docker machine ip>:2080
The machine IP can be seen when launching Docker Quickstart or using:
docker-machine env
# mysql
localhost:13306
# client
http://localhost:1080
# server
http://localhost:2080
# mysql
mariadb:3306
# client
http://client:80
# server
http://server:80
docker exec -it sam_server_1 /bin/bash
# for client use "sam_client_1"
docker exec -it sam_server_1 phalcon
docker exec -it sam_server_1 composer
docker run -it --rm -v $(pwd)/server:/app amqamq/webtools [ruby|sass|node|npm|grunt|gulp|bower]
docker run -it --rm \
--network=$(docker network ls -f "name=sam_default" -q) \
-v $(pwd)/server:/app \
debian:jessie \
/bin/bash
-
Clone Phalcon Devtools in your home directory:
cd ~ git clone https://github.com/phalcon/phalcon-devtools
-
In PhpStorm - File - Settings - Languages & Frameworks - PHP:
PHP language level: 7
Include path:
<home dir>\phalcon-devtools\ide\stubs
egC:\Users\abc\phalcon-devtools\ide\stubs
-
Save the bookmarks for start debugger and stop debugger from jetbrains.com/phpstorm/marklets/
-
In PhpStorm in the top right corner, press Start listening for PHP debug connections
-
Set some breakpoint
-
Open the page with the breakpoint, click on the start debugging bookmark and reload the page
-
PhpStorm window should become active and will ask you to accept an incoming connection, press Accept. Now you should see the variables in Debugger
No extra configuration is required. Xdebug expects any remote_host
, any idekey
and remote_port=9000
-
PhpStorm - File - Settings - Languages & Frameworks - PHP - CLI Interpreter
-
Plus sign in the top left corner - Remote...
-
Select Docker and set Image name to
amqamq/phalcon:nginx
-
Edit
client/docker/php-dev.ini
, by adding, for example:memory_limit = 256M
-
Restart
docker-compose
:docker-compose restart
-
Launch a Linux server with any provider
-
Open ports
22, 80, 443, 2376, 2377, 7946, 7946, 4789
-
Provision Docker from your local machine:
docker-machine create --driver=generic --generic-ip-address=1.2.3.4 --generic-ssh-key=key.pem --generic-ssh-user=user sam101
-
Check the available machines:
docker-machine ls
-
Change you local environmental variables to reflect the remote machine:
eval "$(docker-machine env sam101)"
-
Check what containers are running on the remote machine (should be none):
docker ps
-
Copy
prod.env.example
toprod.env
and edit it accordingly -
Deploy
docker-compose -f docker-compose-prod.yml up -d
The deployment includes v2tec/watchtower
which automatically updates the containers on image pushes (handled by Travis)
Most probably you have just upgraded the Toolbox or VirtualBox. A reboot should solve the problem
Make sure your docker-compose
version is 1.6.0 or newer:
docker-compose --version
-
the IP is wrong. Make sure to use the one shown by Docker Quickstart
-
the shared folders are broken. Make sure that the mount in VirtualBox machine settings is exactly:
/c/Users C:\Users
then restart the machine:
docker-machine restart
Run on your local machine:
chmod 777 client/cache
chmod 777 server/cache
Workaround: set a user environment variable in Control panel:
COMPOSE_CONVERT_WINDOWS_PATHS=1
- library/mariadb
- amqamq/phalcon (based on library/php and library/nginx)
- amqamq/webtools
All are based on debian:jessie
. We will consider switching to alpine
when mariadb
gets an official support for it