{"id":21062167,"url":"https://github.com/rollmug/directus-mysql-template","last_synced_at":"2025-05-16T02:30:57.374Z","repository":{"id":65189733,"uuid":"586609087","full_name":"rollmug/directus-mysql-template","owner":"rollmug","description":"Node helper app for Docker compose with Directus + MySQL + GraphiQL","archived":false,"fork":false,"pushed_at":"2024-12-20T14:37:23.000Z","size":326,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-16T06:23:06.859Z","etag":null,"topics":["directus","docker","docker-compose","graphql","mysql"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/rollmug.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2023-01-08T18:23:06.000Z","updated_at":"2025-01-04T09:19:59.000Z","dependencies_parsed_at":"2023-10-11T15:25:50.911Z","dependency_job_id":"4cb681f6-0b35-4832-a4c0-5de6beca18dd","html_url":"https://github.com/rollmug/directus-mysql-template","commit_stats":null,"previous_names":[],"tags_count":5,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollmug%2Fdirectus-mysql-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollmug%2Fdirectus-mysql-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollmug%2Fdirectus-mysql-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollmug%2Fdirectus-mysql-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rollmug","download_url":"https://codeload.github.com/rollmug/directus-mysql-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254455712,"owners_count":22074041,"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":["directus","docker","docker-compose","graphql","mysql"],"created_at":"2024-11-19T17:37:40.591Z","updated_at":"2025-05-16T02:30:57.368Z","avatar_url":"https://github.com/rollmug.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Docker with Directus / MySQL / Adminer / GraphQL\n\nThis package contains everything you need to get up and running with Directus CMS with a MySQL backend, plus an interactive GraphQL playground to help you develop your API queries.\n\n**Requirements:** you need [Docker](https://www.docker.com) and [Node](https://nodejs.org) installed on your machine:\n\n- [Install Docker Desktop](https://www.docker.com/products/docker-desktop/)  \n- [Install Node](https://nodejs.org/en/download/)\n\n### Quick Install:\n\n**The easiest way to get up and running is to open a terminal session and run:**\n\n```bash\nnpx create-directus-docker@latest \u003cmy-project\u003e\n```\n\nThen, just follow the on-screen prompts.\n\n### Manual Install\n\nAs an alternative, you can install this package by following these steps. Once you've installed Node and Docker, and have Docker Desktop running on your machine:\n\n1. Open a terminal session:  \n    **Mac:** Go to /Applications/Utilities then double-click Terminal.  \n    **Windows:** Click 'Start' taskbar button, Select 'All apps', scroll down and select 'Terminal'\n2. CD into the parent directory where you'd like to install this, ie `cd '~/Documents/My-Folder'`.\n3. From there, run:  \n    `git clone https://github.com/rollmug/directus-mysql-template.git`  \n    OR, if you don't have git installed, [manually download it here](https://github.com/rollmug/directus-mysql-template/archive/refs/heads/main.zip) and unzip it.\n4. Navigate into the folder you just downloaded, ie `cd 'directus-mysql-template'`\n\n**Configure your Directus/MySQL setup:**\n\n1. Within the directus-mysql-template directory, run `npm install`\n2. Lastly, run `npm start`. The wizard will walk you through the config, and automatically launch all containers for you.\n\n*Note that you'll only have to do these two steps the first time you run this.*\n\n### Permissions\n\nYou may need to grant additional access to the 'directus' directory, so that Directus can create files there. Just run:\n\n```\nsudo chmod -R 777 directus\n```\n\n### Seeding MySQL data\n\nIf you want to seed your database with data on first launch, place your .sql file(s) in the \"init\" directory at the root of this package. MySQL will run any files in this directory the first time it launches.\n\n### Starting/stopping with Docker Compose\n\nTo **stop** your running containers, simply run `docker compose down` in your terminal from within the project directory. All containers will be stopped.\n\nTo **restart** your stopped containers, you can let the helper app do it for you:\n\n`npm start`\n\nOr you can follow this sequence:\n\n`docker compose up mysql -d`\n\nThen wait 10-20 seconds (for MySQL to boot), then type:\n\n`docker compose up -d`\n\n**Boom!** You're done. Now you can access the URLS from here:\n\nDirectus CMS: http://localhost:8055  \nApollo GraphQL Sandbox: https://studio.apollographql.com/sandbox/explorer?endpoint=http://localhost:8055/graphql  \nAdminer (for MySQL): http://localhost:8080\n\n**Check on running containers:**\n\nSimply run `docker compose ps` to see the status of running containers. Or, run `docker compose ps -a` to see all containers, running or not.\n\n### NGINX Proxy example\n\nIncluded in this package is also a `docker-compose-nginx.yml` file that demonstrates how to run a reverse proxy on a Linux-based server so that you can use a custom domain with an auto-generated/renewed SSL certificate via Let's Encrypt.\n\nTo use this, rename the existing `docker-compose.yml` file to something else, and rename the `docker-compose-nginx.yml` to `docker-compose.yml`.\n\nAdd the following env variables to your `.env` file:\n\n```bash\nVIRTUAL_HOST=\"your-domain.com\"\nCERT_EMAIL=\"you@email\"\n```\n\nand make sure your Directus .env variables look something like this:\n\n```bash\nDIRECTUS_DOMAIN=\"localhost\"\nDIRECTUS_PORT=\"8055\"\nPUBLIC_URL=\"https://your-domain.com\"\nAPI_ENDPOINT=\"https://your-domain.com/graphql\"\n```\n\nLastly, before running `npm start`, make sure you have pointed to your domain's DNS to your server using the appropriate A records.\n\nNote: you may need to adjust or disable your firewall before running this, to ensure that the SSL certificate can be properly generated using the included `acme-companion` container for Let's Encrypt.\n\n### Snapshot the Data Model\n\nDirectus can automatically generate a snapshot of your current data model in YAML format. This includes all collections, fields, and relations, and their configuration. This snapshot can be checked in version control and shared with your team. To generate the snapshot, run:\n\n`npm run snapshot`\n\nThe 'directus' container **must be running** in order to take a snapshot.\n\n### Apply a Snapshot\n\nTo overwrite the current Directus instance with the data model specified in that snapshot, you can apply a snapshot by running:\n\n`npm run snapshot-apply --snapshot=snapshot-file.yaml`\n\nChange the name of the file in the command to match an actual snapshot file in your 'snapshots' directory.\n\nBy applying the snapshot, Directus will auto-detect the changes required to make the current instance up to date with the proposed data model in the snapshot file, and will run the required migrations to the database to make it match the snapshot. This is useful when migrating to/from another directus instance.\n\n**It is recommended that you test this first by doing a dry-run like this:**\n\n`npm run snapshot-test --snapshot=snapshot-file.yaml`\n\n### Examples of getting an auth token for Directus API:\n\ncurl -X POST localhost:8055/auth/login -H 'Content-Type: application/json' -d '{\"email\":\"you@email.com\",\"password\":\"your-password\"}'\n\ncurl -X POST localhost:8055/auth/refresh -H 'Content-Type: application/json' -d '{\"refresh_token\": \"W5L70MBXKElx5ZVZwxmQVG8qdVjukiRVIwD5FYG7tCPyyuCM_I3IyCsYnFhMUrRi\", \"mode\": \"json\"}'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frollmug%2Fdirectus-mysql-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frollmug%2Fdirectus-mysql-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frollmug%2Fdirectus-mysql-template/lists"}