{"id":17989572,"url":"https://github.com/evilfreelancer/docker-craftcms","last_synced_at":"2025-03-25T23:30:50.470Z","repository":{"id":110656665,"uuid":"142763123","full_name":"EvilFreelancer/docker-craftcms","owner":"EvilFreelancer","description":"Extra small image with basic CraftCMS inside Docker container","archived":false,"fork":false,"pushed_at":"2021-07-18T21:01:00.000Z","size":104,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T22:10:11.371Z","etag":null,"topics":["automated-build","craftcms","docker"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/evilfreelancer/docker-craftcms/","language":"Shell","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/EvilFreelancer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-29T13:26:55.000Z","updated_at":"2021-07-18T21:00:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"0f70fd03-4bca-456e-83c8-68efb796772d","html_url":"https://github.com/EvilFreelancer/docker-craftcms","commit_stats":null,"previous_names":[],"tags_count":403,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fdocker-craftcms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fdocker-craftcms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fdocker-craftcms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EvilFreelancer%2Fdocker-craftcms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EvilFreelancer","download_url":"https://codeload.github.com/EvilFreelancer/docker-craftcms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245561191,"owners_count":20635691,"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":["automated-build","craftcms","docker"],"created_at":"2024-10-29T19:14:59.159Z","updated_at":"2025-03-25T23:30:50.421Z","avatar_url":"https://github.com/EvilFreelancer.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![MicroBadger Size](https://img.shields.io/microbadger/image-size/evilfreelancer/docker-craftcms.svg)](https://hub.docker.com/r/evilfreelancer/docker-craftcms/)\n[![MicroBadger Layers](https://img.shields.io/microbadger/layers/evilfreelancer/docker-craftcms.svg)](https://hub.docker.com/r/evilfreelancer/docker-craftcms/)\n[![Docker Pulls](https://img.shields.io/docker/pulls/evilfreelancer/docker-craftcms.svg)](https://hub.docker.com/r/evilfreelancer/docker-craftcms/)\n\n# CraftCMS inside Docker container\n\nExtra small image with basic CraftCMS inside Docker container, based on\nAlpine Linux with latest PHP (which available from repository of stable Alpine of\ncourse).\n\nList of [available tags](https://hub.docker.com/r/evilfreelancer/docker-craftcms/tags/).\n\n## How to use\n\n### Via Dockerfile\n\nIf you want to use this image, but you want to add source code of\nyour application with dependencies, then you need create `Dockerfile`\nwith content like below in root of your existing CraftCMS project:\n\n```dockerfile\nFROM evilfreelancer/docker-craftcms\n\n# You can add any folders or files to /app folder in container\nADD [\"composer.json\". \"templates/\", \"/app\"]\n# For example in resources you have additional js, css, img etc. files\nADD [\"web/resources/\", \"/app/resources\"]\nWORKDIR /app\n\nRUN composer update \\\n \u0026\u0026 chown -R apache:apache /app\n```\n\nFor building you need just run:\n\n```bash\ndocker build . --tag craftcms-local\n```\n\nThe image [alpine-apache-php7](https://hub.docker.com/r/evilfreelancer/alpine-apache-php7/)\nhas `80` port exposed (apache2 here) by default, so you just need plug your local\nport with port of container together:\n\n```bash\ndocker run -e SECURITY_KEY=somekey -d -p 80:80 craftcms-local\n```\n\nFor example you want to mount some external folders `/opt/nfs/assets`\nwith static files (images, documents, etc.) or logs to your container, \nyou need to use `-v` (that mean \"volume\") key:\n\n```bash\ndocker run \\\n    -v ./craft/storage:/app/storage \\\n    -v ./craft/vendor:/app/vendor \\\n    -v ./craft/web/cpresources:/app/web/cpresources \\\n    -v /opt/nfs/assets:/app/web/assets \\\n    -e SECURITY_KEY=somekey \\\n    -p 80:80 \\\n    -d craftcms-local\n```\n\n### Via command line\n\nYou can pull latest (same as with :latest) version of CraftCMS engine from Docker Hub\n(will be downloaded latest stable version, eg 3.9.99):\n\n```bash\ndocker pull evilfreelancer/docker-craftcms\n```\n\nOr set the tag which you need:\n\n```bash\ndocker pull evilfreelancer/docker-craftcms:3.1.18\n```\n\nOr minor stable version (will be downloaded latest stable version in 3.1 release, eg. 3.1.99):\n\n```bash\ndocker pull evilfreelancer/docker-craftcms:3.1\n```\n\nOr major stable version (will be downloaded latest stable version, eg. 3.9.99):\n\n```bash\ndocker pull evilfreelancer/docker-craftcms:3\n```\n\nThen start the container:\n\n```bash\ndocker run -e SECURITY_KEY=somekey -d -p 80:80 docker-craftcms\n```\n\n### Via docker-compose\n\nIf you need MySQL with CraftCMS the you need create the\n`docker-compose.yml` file and put inside following content:\n\n```yml\nversion: \"2\"\n\nservices:\n\n  # You can use MySQL, MariaDB or PostgreSQL image\n  mysql:\n    image: mysql:5.7\n    restart: unless-stopped\n    ports:\n      - 3306:3306\n    environment:\n      - MYSQL_DATABASE=craft-production\n      - MYSQL_ROOT_PASSWORD=root_pass\n      - MYSQL_USER=craft\n      - MYSQL_PASSWORD=craft_pass\n    volumes:\n      - ./databases/mysql:/var/lib/mysql\n      - ./logs/mysql:/var/log/mysql\n\n  craftcms:\n    image: evilfreelancer/docker-craftcms:3\n    restart: unless-stopped\n    ports:\n      - 80:80\n    environment:\n      # Security key is very important\n      - SECURITY_KEY=somekey\n      - DB_DSN=mysql:host=mysql;port=3306;dbname=craft-production\n      - DB_USER=craft\n      - DB_PASSWORD=craft_pass\n      # - DB_DSN: pgsql:host=postgres;port=5432;dbname=craft-production\n      # - DB_USER: postgres\n      # - DB_PASSWORD: ''\n      # - DB_SCHEMA: public\n      # - DB_TABLE_PREFIX: ''\n    volumes:\n      # Storage with system logs, cache etc.\n      - ./craft/storage/logs:/app/storage/logs\n      - ./craft/storage/runtime/cache/us:/app/storage/runtime/cache/us\n      # Temapltes of website for development stage\n      - ./craft/templates:/app/templates\n      # Plugins installed to your project (but better use \"docker build context\" with custom Dockerfile, example above)\n      - ./craft/vendor:/app/vendor\n      # Static files, with images, js, css, etc.\n      - ./craft/web/cpresources:/app/web/cpresources\n      - ./craft/web/assets:/app/web/assets\n      - ./craft/web/resources:/app/web/resources\n      # ... list of any other folders/files which you need\n```\n\nRun this composition of containers:\n\n```bash\ndocker-compose up -d\n```\n\nNow need fix permissions to importnat folders, it should be `apache:apache`.\n\n```bash\n# Login to craftcms container\ndocker-compose exec craftcms bash\n\n# Fix permissions from inside of container\nchown apache:apache .env\nchown apache:apache composer.json\nchown apache:apache composer.lock\nchown apache:apache config/license.key\nchown apache:apache -R storage\nchown apache:apache -R vendor\nchown apache:apache -R web/cpresources\n```\n\nIf you mounted `storage`, `vendor`, `web/cpresources` from real drive\nthen changes will be saved.  \n\nBut how to update the CraftCMS image? That's easy, if you use `:latest`\ntag of docker image then you just need:\n\n```bash\ndocker-compose pull\ndocker-compose up -d\n```\n\nAnd your CraftCMS container will be recreated if new version of CraftCMS\ncontainer pushed added in repository.\n\n## Almost done\n\nNow you need just open this url http://localhost and you'll see the CraftCMS magic.\nBut do not worry if you see the error message, you need install the engine, for this\nyou need open http://localhost/index.php?p=admin/install page and follow the instruction.\n\n## Links\n\n* [alpine-apache-php7](https://hub.docker.com/r/evilfreelancer/alpine-apache-php7/)\n* [CraftCMS](https://github.com/craftcms/craft)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilfreelancer%2Fdocker-craftcms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevilfreelancer%2Fdocker-craftcms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilfreelancer%2Fdocker-craftcms/lists"}