{"id":13684650,"url":"https://github.com/stefanvangastel/docker-cakephp","last_synced_at":"2026-01-30T12:19:15.699Z","repository":{"id":20122264,"uuid":"23392173","full_name":"stefanvangastel/docker-cakephp","owner":"stefanvangastel","description":"Example Dockerfile for deploying a CakePHP application in a Docker container, able to connect to a remote database with database-based sessions.","archived":false,"fork":false,"pushed_at":"2019-11-09T09:48:10.000Z","size":26,"stargazers_count":31,"open_issues_count":0,"forks_count":27,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-08-03T14:07:54.550Z","etag":null,"topics":["cakephp","cakephp-application","docker","docker-cakephp","docker-container","dockerfile","mysql-container","ubuntu"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefanvangastel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-27T14:17:50.000Z","updated_at":"2023-05-12T16:40:51.000Z","dependencies_parsed_at":"2022-08-03T15:10:17.308Z","dependency_job_id":null,"html_url":"https://github.com/stefanvangastel/docker-cakephp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanvangastel%2Fdocker-cakephp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanvangastel%2Fdocker-cakephp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanvangastel%2Fdocker-cakephp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanvangastel%2Fdocker-cakephp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanvangastel","download_url":"https://codeload.github.com/stefanvangastel/docker-cakephp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224230571,"owners_count":17277372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cakephp","cakephp-application","docker","docker-cakephp","docker-container","dockerfile","mysql-container","ubuntu"],"created_at":"2024-08-02T14:00:36.307Z","updated_at":"2026-01-30T12:19:15.661Z","avatar_url":"https://github.com/stefanvangastel.png","language":"Dockerfile","readme":"docker-cakephp\n======================\n\nDockerfile 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.\n\nBased on Ubuntu 16.04 Xenial and PHP 7.0\n\n**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.**\n\nUsage\n-----\n\nYou can edit the `Dockerfile` to add your own git, composer or custom commands to add your application code to the image.\n\nTo create the image `myvendor/mycakephpapp`, execute the following command on the docker-cakephp directory:\n\n```bash\ndocker build -t myvendor/mycakephpapp .\n```\n\nOptional: You can now push your new image to a registry:\n\n```bash\ndocker push myvendor/mycakephpapp\n```\n\nRunning your CakePHP docker image\n-----------------------------------\n\nStart your image forwarding container port 80 to localhost port 80:\n\n```bash\ndocker run -d -p 80:80 myvendor/mycakephpapp\n```\n\nExample: Connecting to a MySQL container\n-----------------------------------\nStart a [MySQL container](https://hub.docker.com/_/mysql/) \n\n```bash\ndocker run -d \\\n\t--name mysql-server \\\n\t-e MYSQL_ROOT_PASSWORD=sekret \\\n\t-e MYSQL_DATABASE=cakephp \\\n\tmysql:5.7\n```\n\nStart your image and:\n* Link it to the MySQL container you just started (so your container can contact it)\n* Connect to a remote database server using the CakePHP DATABASE_URL env variable filled with the variables given in the command above.\n* Use the `database` session handler using our the SESSION_DEFAULTS env variable (see `Dockerfile` for implementation)\n\n```bash\ndocker run -d -p 80:80 \\\n\t--name cakephp \\\n\t-e \"DATABASE_URL=mysql://root:sekret@mysql-server/cakephp?encoding=utf8\u0026timezone=UTC\u0026cacheMetadata=true\" \\\n\t-e \"SESSION_DEFAULTS=database\" \\\n\t--link mysql-server:mysql \\\n\tmyvendor/mycakephpapp\n```\n\n\nTest your deployment\n--------------------------\n\nVisit `http://localhost/` in your browser or \n\n\tcurl http://localhost/\n\nYou can now start using your CakePHP container!\n\nThings to look out for\n-----------------------------------\n* 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.\n* 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`](https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-directory-as-a-data-volume) or an object storage with a webservice interface like Amazon S3. \n","funding_links":[],"categories":["Development Environment"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanvangastel%2Fdocker-cakephp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanvangastel%2Fdocker-cakephp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanvangastel%2Fdocker-cakephp/lists"}