npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-directus-docker

v1.6.6

Published

An installer for Dockerized Directus + MySQL + Adminer + GraphQL Sandbox with a helper Node app

Downloads

326

Readme

Docker with Directus / MySQL / Adminer / GraphQL

A quick-start installer and launcher for Docker compose, containing Directus with MySQL, an Adminer UI for managing the database, and a GraphiQL playground. Plus a helper app to walk you through initializing environment variables and launching all services.

Requirements: you need Docker and Node installed on your machine:

Installation & Usage

The easiest way to get up and running is to open a terminal session and run:

npx create-directus-docker@latest <my-project>

Once installed, simply run:

cd <my-project>
npm install
npm start

The wizard will walk you through configuring your environment variables, and will launch all services for you.

Seeding MySQL data

If 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.

Starting/stopping with Docker Compose

To stop your running containers, simply run docker compose down in your terminal from within the project directory. All containers will be stopped.

To restart your stopped containers, you can let the helper app do it for you:

npm start

Or you can follow this sequence:

docker compose up mysql -d

Then wait 10-20 seconds (for MySQL to boot), then type:

docker compose up -d

Boom! You're done. Now you can access the URLS from here:

Directus CMS: http://localhost:8055
Apollo GraphQL Sandbox: https://studio.apollographql.com/sandbox/explorer?endpoint=http://localhost:8055/graphql
Adminer (for MySQL): http://localhost:8080

Check on running containers:

Simply run docker compose ps to see the status of running containers. Or, run docker compose ps -a to see all containers, running or not.

NGINX Proxy example

Included 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.

To use this, rename the existing docker-compose.yml file to something else, and rename the docker-compose-nginx.yml to docker-compose.yml.

Add the following env variables to your .env file:

VIRTUAL_HOST="your-domain.com"
CERT_EMAIL="you@email"

and make sure your Directus .env variables look something like this:

DIRECTUS_DOMAIN="localhost"
DIRECTUS_PORT="8055"
PUBLIC_URL="https://your-domain.com"
API_ENDPOINT="https://your-domain.com/graphql"

Lastly, before running npm start, make sure you have pointed to your domain's DNS to your server using the appropriate A records.

Note: 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.

Snapshot the Data Model

Directus 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:

npm run snapshot

The 'directus' container must be running in order to take a snapshot.

Apply a Snapshot

To overwrite the current Directus instance with the data model specified in that snapshot, you can apply a snapshot by running:

npm run snapshot-apply --snapshot=snapshot-file.yaml

Change the name of the file in the command to match an actual snapshot file in your 'snapshots' directory.

By 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.

It is recommended that you test this first by doing a dry-run like this:

npm run snapshot-test --snapshot=snapshot-file.yaml

Examples of getting an auth token for Directus API:

curl -X POST localhost:8055/auth/login -H 'Content-Type: application/json' -d '{"email":"[email protected]","password":"your-password"}'

curl -X POST localhost:8055/auth/refresh -H 'Content-Type: application/json' -d '{"refresh_token": "W5L70MBXKElx5ZVZwxmQVG8qdVjukiRVIwD5FYG7tCPyyuCM_I3IyCsYnFhMUrRi", "mode": "json"}'