{"id":20313906,"url":"https://github.com/craftcms/docker","last_synced_at":"2025-04-05T03:12:28.339Z","repository":{"id":37088622,"uuid":"280698331","full_name":"craftcms/docker","owner":"craftcms","description":"Craft CMS Docker images.","archived":false,"fork":false,"pushed_at":"2024-12-19T17:08:38.000Z","size":268,"stargazers_count":103,"open_issues_count":20,"forks_count":37,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-29T02:09:12.098Z","etag":null,"topics":["cli","container","craft-cms","craft-docker-images","craftcms","devops","docker","nginx","php-fpm"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/craftcms.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2020-07-18T16:46:18.000Z","updated_at":"2025-03-13T22:23:51.000Z","dependencies_parsed_at":"2024-04-18T18:33:34.876Z","dependency_job_id":"5bc0d75b-fd42-467d-8904-77dfb59ee249","html_url":"https://github.com/craftcms/docker","commit_stats":null,"previous_names":[],"tags_count":404,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftcms%2Fdocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftcms%2Fdocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftcms%2Fdocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftcms%2Fdocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/craftcms","download_url":"https://codeload.github.com/craftcms/docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"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":["cli","container","craft-cms","craft-docker-images","craftcms","devops","docker","nginx","php-fpm"],"created_at":"2024-11-14T18:13:27.145Z","updated_at":"2025-04-05T03:12:28.324Z","avatar_url":"https://github.com/craftcms.png","language":"Dockerfile","readme":"# Craft Docker Images\n\n\u003e _Note_: We are going to deprecate these images and archive this repository. Please see [this issue](https://github.com/craftcms/docker/issues/93) for additional details. New images are located at [craftcms/image](https://github.com/craftcms/image).\n\nThese images are provided as a starting point for your Docker-based Craft CMS deployments. They’re discrete, lightweight, and pre-configured to meet Craft’s requirements in production and development environments.\n\n## Images\n\nThere are three main \"types\" of images provided for different types of applications; `php-fpm`, `nginx`, and `cli`. Each image allows the developer to select a PHP version (e.g. `craftcms/nginx:8.2`).\n\nEach image and PHP version also provides a `-dev` variant which has Xdebug installed and is useful for local development (e.g. `craftcms/php-fpm:8.2-dev`), as well as database tools for creating and restoring backups. Images that do not include `-dev` are considered production.\n\n\u003e Note: you are not required to use `-dev` images for local development, they are provided with Xdebug and to make debugging easier.\n\nTo keep the production images lean and secure, database tools are NOT included by default (they are included in the `-dev` variants). If you want to create database backups from the Craft control panel, you will need to [install these yourself](#database-tools).\n\nSupported PHP versions are aligned with [PHP's official support](https://www.php.net/supported-versions.php), meaning that once a PHP version is EOL, we will no longer build new images for that version.\n\n### php-fpm\n\n[![craftcms/php-fpm](https://img.shields.io/docker/pulls/craftcms/php-fpm.svg)](https://hub.docker.com/r/craftcms/php-fpm)\n\nThe `php-fpm` image is provided as the base image (and is also used for the `nginx` image) and requires you \"bring your own server\".\n\n| Image                      | Use | Environment   | Status            |\n| -------------------------- | --- | ------------- | ----------------- |\n| `craftcms/php-fpm:8.2`     | web | `production`  |                   |\n| `craftcms/php-fpm:8.2-dev` | web | `development` |                   |\n| `craftcms/php-fpm:8.1`     | web | `production`  |                   |\n| `craftcms/php-fpm:8.1-dev` | web | `development` |                   |\n| `craftcms/php-fpm:8.0`     | web | `production`  | EOL on 2023-11-26 |\n| `craftcms/php-fpm:8.0-dev` | web | `development` | EOL on 2023-11-26 |\n| `craftcms/php-fpm:7.4`     | web | `production`  | EOL               |\n| `craftcms/php-fpm:7.4-dev` | web | `development` | EOL               |\n| `craftcms/php-fpm:7.3`     | web | `production`  | EOL               |\n| `craftcms/php-fpm:7.3-dev` | web | `development` | EOL               |\n| `craftcms/php-fpm:7.2`     | web | `production`  | EOL               |\n| `craftcms/php-fpm:7.2-dev` | web | `development` | EOL               |\n| `craftcms/php-fpm:7.1`     | web | `production`  | EOL               |\n| `craftcms/php-fpm:7.1-dev` | web | `development` | EOL               |\n| `craftcms/php-fpm:7.0`     | web | `production`  | EOL               |\n| `craftcms/php-fpm:7.0-dev` | web | `development` | EOL               |\n\n### Nginx\n\n[![craftcms/nginx](https://img.shields.io/docker/pulls/craftcms/nginx.svg)](https://hub.docker.com/r/craftcms/nginx)\n\nThe `nginx` image is used for a typical installation and includes an Nginx server configured for Craft CMS and php-fpm.\n\n| Image                    | Use | Environment   | Status            |\n| ------------------------ | --- | ------------- | ----------------- |\n| `craftcms/nginx:8.2`     | web | `production`  |                   |\n| `craftcms/nginx:8.2-dev` | web | `development` |                   |\n| `craftcms/nginx:8.1`     | web | `production`  |                   |\n| `craftcms/nginx:8.1-dev` | web | `development` |                   |\n| `craftcms/nginx:8.0`     | web | `production`  | EOL on 2023-11-26 |\n| `craftcms/nginx:8.0-dev` | web | `development` | EOL on 2023-11-26 |\n| `craftcms/nginx:7.4`     | web | `production`  | EOL               |\n| `craftcms/nginx:7.4-dev` | web | `development` | EOL               |\n| `craftcms/nginx:7.3`     | web | `production`  | EOL               |\n| `craftcms/nginx:7.3-dev` | web | `development` | EOL               |\n| `craftcms/nginx:7.2`     | web | `production`  | EOL               |\n| `craftcms/nginx:7.2-dev` | web | `development` | EOL               |\n| `craftcms/nginx:7.1`     | web | `production`  | EOL               |\n| `craftcms/nginx:7.1-dev` | web | `development` | EOL               |\n| `craftcms/nginx:7.0`     | web | `production`  | EOL               |\n| `craftcms/nginx:7.0-dev` | web | `development` | EOL               |\n\n### cli\n\n[![craftcms/cli](https://img.shields.io/docker/pulls/craftcms/cli.svg)](https://hub.docker.com/r/craftcms/cli)\n\nThe image type `cli` which is used to run queues, migrations, etc. and the image does not expose ports for HTTP/S or PHP-FPM.\n\n| Image                  | Use | Environment   | Status            |\n| ---------------------- | --- | ------------- | ----------------- |\n| `craftcms/cli:8.2`     | web | `production`  |                   |\n| `craftcms/cli:8.2-dev` | web | `development` |                   |\n| `craftcms/cli:8.1`     | web | `production`  |                   |\n| `craftcms/cli:8.1-dev` | web | `development` |                   |\n| `craftcms/cli:8.0`     | web | `production`  | EOL on 2023-11-26 |\n| `craftcms/cli:8.0-dev` | web | `development` | EOL on 2023-11-26 |\n| `craftcms/cli:7.4`     | web | `production`  | EOL               |\n| `craftcms/cli:7.4-dev` | web | `development` | EOL               |\n| `craftcms/cli:7.3`     | web | `production`  | EOL               |\n| `craftcms/cli:7.3-dev` | web | `development` | EOL               |\n| `craftcms/cli:7.2`     | web | `production`  | EOL               |\n| `craftcms/cli:7.2-dev` | web | `development` | EOL               |\n| `craftcms/cli:7.1`     | web | `production`  | EOL               |\n| `craftcms/cli:7.1-dev` | web | `development` | EOL               |\n| `craftcms/cli:7.0`     | web | `production`  | EOL               |\n| `craftcms/cli:7.0-dev` | web | `development` | EOL               |\n\n## Usage\n\nThere are two main types of images: `php-fpm` for handling the web application, and `cli` for running queues and other Craft CLI commands. Additionally, we provide an `nginx` image, which combines `php-fpm` and `nginx` into a single image for simplicity and ease of development.\n\nThis example uses a Docker [multi-stage build](https://docs.docker.com/develop/develop-images/multistage-build/) to install composer dependencies inside a separate layer before copying them into the final image.\n\n```dockerfile\n# use a multi-stage build for dependencies\nFROM composer:2 as vendor\nCOPY composer.json composer.json\nCOPY composer.lock composer.lock\nRUN composer install --ignore-platform-reqs --no-interaction --prefer-dist\n\nFROM craftcms/php-fpm:8.2\n\n# the user is `www-data`, so we copy the files using the user and group\nCOPY --chown=www-data:www-data --from=vendor /app/vendor/ /app/vendor/\nCOPY --chown=www-data:www-data . .\n```\n\n### Database tools\n\nThis example uses the `craftcms/nginx` repository and installs the database tools to enable backups from the Craft CMS control panel. Note: These will be included automatically if using the `-dev` image variants.\n\n```dockerfile\n# composer dependencies\nFROM composer:2 as vendor\nCOPY composer.json composer.json\nCOPY composer.lock composer.lock\nRUN composer install --ignore-platform-reqs --no-interaction --prefer-dist\n\nFROM craftcms/nginx:8.2\n\n# switch to the root user to install mysql tools\nUSER root\nRUN apk add --no-cache mysql-client postgresql-client\nUSER www-data\n\n# the user is `www-data`, so we copy the files using the user and group\nCOPY --chown=www-data:www-data --from=vendor /app/vendor/ /app/vendor/\nCOPY --chown=www-data:www-data . .\n```\n\n## Permissions\n\nThe image is designed to be run by a `www-data` user that owns of the image’s `/app` directory. Running as non-root is considered a Docker best practice, especially when shipping container images to production.\n\n\u003e Note: You can use the `USER root` directive to switch back to `root` to install any additional packages you need.\n\n## Running Locally with Docker Compose\n\nWe recommend running Docker locally if you’re shipping your project to a Docker-based environment such as Amazon Web Services Elastic Container Services (ECS). The following Docker Compose file will setup your local environment with the following:\n\n1. `web` service that will handle running PHP and Nginx\n2. `postgres` service that will store your content\n3. `console` service that will run the queue locally\n4. `redis` service that will handle queue and caching\n\n```yaml\nversion: \"3.6\"\nservices:\n  console:\n    image: craftcms/cli:8.2-dev\n    env_file: .env\n    environment:\n      XDEBUG_CONFIG: client_host=host.docker.internal\n    depends_on:\n      postgres:\n        condition: service_healthy\n      redis:\n        condition: service_healthy\n    volumes:\n      - .:/app\n    command: php craft queue/listen\n\n  web:\n    image: craftcms/nginx:8.2-dev\n    ports:\n      - 8080:8080\n    env_file: .env\n    environment:\n      XDEBUG_CONFIG: client_host=host.docker.internal\n    depends_on:\n      postgres:\n        condition: service_healthy\n      redis:\n        condition: service_healthy\n    volumes:\n      - .:/app\n\n  postgres:\n    image: postgres:13-alpine\n    ports:\n      - 5432:5432\n    environment:\n      POSTGRES_DB: dev_craftcms\n      POSTGRES_USER: craftcms\n      POSTGRES_PASSWORD: SecretPassword\n    volumes:\n      - db_data:/var/lib/postgresql/data\n    healthcheck:\n      test: [\"CMD\", \"pg_isready\", \"-U\", \"craftcms\", \"-d\", \"dev_craftcms\"]\n      interval: 5s\n      retries: 3\n\n  redis:\n    image: redis:5-alpine\n    ports:\n      - 6379:6379\n    healthcheck:\n      test: [\"CMD\", \"redis-cli\", \"ping\"]\n\nvolumes:\n  db_data:\n```\n\n## Using Xdebug\n\nXdebug is install on the `-dev` image variants, but you will still need to set `xdebug.client_host`.\nWe do not do this in our images, as it is platform-specific. However, if you are on Docker Desktop for Mac or Windows, you can use `host.docker.internal`.\n\nThis can be done via environment variable: `XDEBUG_CONFIG=client_host=host.docker.internal`. [See example](#running-locally-with-docker-compose)\n\n## Installing Extensions\n\nThis image is based off the [official Docker PHP FPM image](https://hub.docker.com/_/php) (Alpine Linux). Therefore you can use all of the tools to install PHP extensions. To install an extension, you have to switch to the `root` user. This example switches to the `root` user to install the [`sockets` extension](https://www.php.net/manual/en/book.sockets.php) for PHP 8.2. Note that it switches back to `www-data` after installation:\n\n```dockerfile\nFROM craftcms/php-fpm:8.2\n\n# switch to the root user\nUSER root\nRUN docker-php-ext-install sockets\nUSER www-data\n\n# the user is www-data, so we copy the files using the user and group\nCOPY --chown=www-data:www-data --from=vendor /app/vendor/ /app/vendor/\nCOPY --chown=www-data:www-data . .\n```\n\n## Customizing PHP Settings\n\nSome PHP settings may be customized by setting environment variables for the `php-fpm` or `cli` images.\n\nIn this example, we’re setting the PHP memory limit to `512M` rather than the default `256M`:\n\n```yaml\nversion: \"3.6\"\nservices:\n  php-fpm:\n    image: craftcms/php-fpm:8.2-dev\n    volumes:\n      - .:/app\n    env_file: .env\n    environment:\n      PHP_MEMORY_LIMIT: 512M\n  # ...\n```\n\n### Customizable Settings\n\n| PHP Setting                       | Environment Variable                  | Default Value |\n| --------------------------------- | ------------------------------------- | ------------- |\n| `memory_limit`                    | `PHP_MEMORY_LIMIT`                    | `256M`        |\n| `max_execution_time`              | `PHP_MAX_EXECUTION_TIME`              | `120`         |\n| `upload_max_filesize`             | `PHP_UPLOAD_MAX_FILESIZE`             | `20M`         |\n| `max_input_vars`                  | `PHP_MAX_INPUT_VARS`                  | `1000`        |\n| `post_max_size`                   | `PHP_POST_MAX_SIZE`                   | `8M`          |\n| `opcache.enable`                  | `PHP_OPCACHE_ENABLE`                  | `1`           |\n| `opcache.revalidate_freq`         | `PHP_OPCACHE_REVALIDATE_FREQ`         | `0`           |\n| `opcache.validate_timestamps`     | `PHP_OPCACHE_VALIDATE_TIMESTAMPS`     | `0`           |\n| `opcache.max_accelerated_files`   | `PHP_OPCACHE_MAX_ACCELERATED_FILES`   | `10000`       |\n| `opcache.memory_consumption`      | `PHP_OPCACHE_MEMORY_CONSUMPTION`      | `256`         |\n| `opcache.max_wasted_percentage`   | `PHP_OPCACHE_MAX_WASTED_PERCENTAGE`   | `10`          |\n| `opcache.interned_strings_buffer` | `PHP_OPCACHE_INTERNED_STRINGS_BUFFER` | `16`          |\n| `opcache.fast_shutdown`           | `PHP_OPCACHE_FAST_SHUTDOWN`           | `1`           |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftcms%2Fdocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcraftcms%2Fdocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftcms%2Fdocker/lists"}