All Projects → stefanvangastel → docker-cakephp

stefanvangastel / docker-cakephp

Licence: MIT License
Example Dockerfile for deploying a CakePHP application in a Docker container, able to connect to a remote database with database-based sessions.

Programming Languages

Dockerfile
14818 projects

Projects that are alternatives of or similar to docker-cakephp

bookmarker-tutorial
The finished result of the bookmarker tutorial. Also serves as a sample application using CakePHP 3.x
Stars: ✭ 24 (-22.58%)
Mutual labels:  cakephp, cakephp-application
vrnetlab
Run virtual routers with docker
Stars: ✭ 879 (+2735.48%)
Mutual labels:  docker-container
another-ldap-auth
LDAP Authentication for Nginx, Nginx ingress controller (Kubernetes), and HAProxy via a subrequest.
Stars: ✭ 30 (-3.23%)
Mutual labels:  docker-container
docker-cheat-sheet
All about docker commands
Stars: ✭ 50 (+61.29%)
Mutual labels:  docker-container
syscall2seccomp
Build custom Docker seccomp profiles for containers by finding syscalls it uses.
Stars: ✭ 71 (+129.03%)
Mutual labels:  docker-container
docker-predictionio
Docker container for PredictionIO-based machine learning services
Stars: ✭ 75 (+141.94%)
Mutual labels:  docker-container
docker-omnidb
OmniDB installed into a Docker container
Stars: ✭ 30 (-3.23%)
Mutual labels:  docker-container
docker-observium
Docker container for Observium Community Edition
Stars: ✭ 37 (+19.35%)
Mutual labels:  docker-container
mixerapi
A CakePHP Plugin for RESTful API Development [READ-ONLY]
Stars: ✭ 26 (-16.13%)
Mutual labels:  cakephp
factorio
Factorio headless server Docker container
Stars: ✭ 25 (-19.35%)
Mutual labels:  docker-container
docker-phpmyadmin
phpMyAdmin as Docker container, based on official image, always latest version
Stars: ✭ 40 (+29.03%)
Mutual labels:  docker-container
docker
🐳 Official Docker image of the SinusBot for TeamSpeak 3 and Discord.
Stars: ✭ 50 (+61.29%)
Mutual labels:  docker-container
cakephp-api-pagination
📑 CakePHP 4 plugin that injects pagination information into API responses.
Stars: ✭ 39 (+25.81%)
Mutual labels:  cakephp
yii2-laradock
Laradock pre-configured for Yii2 Framework (https://github.com/LaraDock/laradock)
Stars: ✭ 16 (-48.39%)
Mutual labels:  docker-container
docker-qbittorrentvpn
Docker container which runs a qBittorent-nox client with an optional WireGuard or OpenVPN connection
Stars: ✭ 76 (+145.16%)
Mutual labels:  docker-container
minicon
Minimization of the filesystem for containers
Stars: ✭ 70 (+125.81%)
Mutual labels:  docker-container
github-status-updater
Command line utility for updating GitHub commit statuses and enabling required status checks for pull requests
Stars: ✭ 83 (+167.74%)
Mutual labels:  docker-container
cakephp-twitter
Twitter webservice plugin for CakePHP
Stars: ✭ 19 (-38.71%)
Mutual labels:  cakephp
CakeShop
eCommerce website with cakephp
Stars: ✭ 19 (-38.71%)
Mutual labels:  cakephp
cakephp-docker
A cakephp/app 4.2 template for Docker and Kubernetes.
Stars: ✭ 17 (-45.16%)
Mutual labels:  cakephp

docker-cakephp

Dockerfile for deploying your CakePHP application in a Docker container, able to connect to a remote database with database-based sessions and inject ENV vars to configure your application.

Based on Ubuntu 16.04 Xenial and PHP 7.0

Note: This project is meant to be an example to study the basics and essentials of CakePHP in a Docker environment, therefore it is build on an Ubuntu base image rather then a PHP base image, uses a 'simple' webserver like Apache and has some non-efficient commands to demonstrate stuff.

Usage

You can edit the Dockerfile to add your own git, composer or custom commands to add your application code to the image.

To create the image myvendor/mycakephpapp, execute the following command on the docker-cakephp directory:

docker build -t myvendor/mycakephpapp .

Optional: You can now push your new image to a registry:

docker push myvendor/mycakephpapp

Running your CakePHP docker image

Start your image forwarding container port 80 to localhost port 80:

docker run -d -p 80:80 myvendor/mycakephpapp

Example: Connecting to a MySQL container

Start a MySQL container

docker run -d \
	--name mysql-server \
	-e MYSQL_ROOT_PASSWORD=sekret \
	-e MYSQL_DATABASE=cakephp \
	mysql:5.7

Start your image and:

  • Link it to the MySQL container you just started (so your container can contact it)
  • Connect to a remote database server using the CakePHP DATABASE_URL env variable filled with the variables given in the command above.
  • Use the database session handler using our the SESSION_DEFAULTS env variable (see Dockerfile for implementation)
docker run -d -p 80:80 \
	--name cakephp \
	-e "DATABASE_URL=mysql://root:sekret@mysql-server/cakephp?encoding=utf8&timezone=UTC&cacheMetadata=true" \
	-e "SESSION_DEFAULTS=database" \
	--link mysql-server:mysql \
	myvendor/mycakephpapp

Test your deployment

Visit http://localhost/ in your browser or

curl http://localhost/

You can now start using your CakePHP container!

Things to look out for

  • Think about handling session when running multiple containers behind a loadbalancer. You could modify the Dockerfile to sed the config/app.php file to use the database or cache session handler as implemented in the example.
  • If you want to store any files (e.g. uploads), please remember containers are 'stateless' and the data will be gone when you delete them. You can use volumes or an object storage with a webservice interface like Amazon S3.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].