Craft CMS: Difference between revisions
Denperidge (talk | contribs) Initial Commit: Setup through Docker |
Denperidge (talk | contribs) Added {{expansion}} |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
{{expansion}} | |||
There is (as of writing) no built-in service for Craft CMS. However, this can be built around with Docker! The following instructions are '''based on''' the [https://craftcms.com/knowledge-base/docker-for-local-development Docker instructions on the Craft CMS website] and experimentation. | There is (as of writing) no built-in service for Craft CMS. However, this can be built around with Docker! The following instructions are '''based on''' the [https://craftcms.com/knowledge-base/docker-for-local-development Docker instructions on the Craft CMS website] and experimentation. | ||
Line 75: | Line 77: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
# Expose 127.0.0.1:4004 so it can be reached by other devices, and navigate to '''example.com/index.php?p=admin/install''' (replacing example.com with your domain or ip:port) | # Expose 127.0.0.1:4004 so it can be reached by other devices, and navigate to '''example.com/index.php?p=admin/install''' (replacing example.com with your domain or ip:port) | ||
[[Category:Applications]] | |||
[[Category:Web Applications]] |
Latest revision as of 09:32, 26 June 2024
There is (as of writing) no built-in service for Craft CMS. However, this can be built around with Docker! The following instructions are based on the Docker instructions on the Craft CMS website and experimentation.
Setup through Docker
- Install Craft CMS
# From https://craftcms.com/knowledge-base/docker-for-local-development # Create and move into a new directory: mkdir craft-docker cd craft-docker # Bootstrap a new Craft installation with Composer: docker run \ --rm \ --volume $PWD:/app \ composer \ composer create-project craftcms/craft . --ignore-platform-reqs
- Create docker-compose.yml
# /home/username/craftcms/docker-compose.yml services: web: image: docker.io/craftcms/nginx:8.2 ports: - "4004:8080" volumes: - /home/username/craft-docker/:/app # Craft CMS installation environment: - CRAFT_DB_DRIVER=pgsql - CRAFT_DB_SERVER=db - CRAFT_DB_PORT=5432 - CRAFT_DB_DATABASE=db - CRAFT_DB_USER=db - CRAFT_DB_PASSWORD=RANDOM - CRAFT_DB_SCHEMA=public - CRAFT_DB_TABLE_PREFIX= depends_on: db: condition: service_healthy db: image: docker.io/postgres:13-alpine expose: - 5432 healthcheck: test: ["CMD", "pg_isready", "-U", "db", "-d", "db"] interval: 5s retries: 3 environment: POSTGRES_DB: db POSTGRES_USER: db POSTGRES_PASSWORD: RANDOM volumes: - db_data:/var/lib/postgresql/data volumes: db_data:
- Modify your NixOS setup along the following lines:
# /etc/nixos/configuration.nix { config, pkgs, ... }: { virtualisation.docker.enable = true; systemd.services.craftcms = { script = "${pkgs.docker-compose}/bin/docker-compose up --force-recreate"; serviceConfig.WorkingDirectory = "/home/username/craftcms/"; # Point to directory with docker-compose.yml # path = with pkgs; [ docker ]; # Uncomment in case docker executable is not found wantedBy = ["multi-user.target"]; after = ["docker.service" "docker.socket"]; }; }
- Expose 127.0.0.1:4004 so it can be reached by other devices, and navigate to example.com/index.php?p=admin/install (replacing example.com with your domain or ip:port)