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

@dympydev/nx-container-apps

v1.0.1

Published

A set of NX generators and executors for container (such as Docker) apps

Downloads

8

Readme

@dympydev/nx-container-apps

Using these generators/executors you can easily add a container application to your NX monorepo. The container applications are based on docker-compose files, by default you can choose one of the templates to get started. If you want to go as barebones as possible, I would suggest picking the nginx_example template and go from there.

The currently supported templates are:

| Template name | Description | More info | | ------------- | ---------------------------------------------------------------------------------------- | -------------------------------------------- | | nginx_example | A simple NGINX web-server, serving a single HTML file (also generated) | NGINX Homepage | | supabase | A local Supabase instance, not meant for production, but has everything to get started! | Supabase Homepage | | pocketbase | A local Pocketbase instance, not meant for production but has everything to get started! | Pocketbase Homepage | | directus | A local Directus instance, not meant for production but has everything to get started! | Directus Homepage |

Generators:

application

The application-generator allows you to add a container application, based on the chosen template, to your NX-monorepo. It integrates with the rest of the NX-ecosystem by using the start and stop executors also present in this plugin. The generated application will contain 3 commands:

  • serve: starts the application and keep the console open for container logs.
  • daemon: starts the application as a daemon (using the -d-flag).
  • stop: executes the compose stop command for the application.

While generating the application, you also have access to a number of options, namely:

| Property | Default | Description | | ---------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | name | | The name for this new NX application. | | template | nginx_example | The template to use, options are mentioned at the top of this document. | | appPort | 3000 | The port the container application should expose, in case of the out-of-the-box template this is automatically mapped to the "port"-property in the start-executors. | | containerTooling | docker | The container-tooling to use, currently only Docker and Podman are supported. In both cases it is up to the user to set-up either docker-compose or podman-compose. | | useDockerV1 | false | Whether to use the old docker-compose syntax (docker-compose ...) or the new V2 variant (docker compose ...). |

Executors:

start

The start-executor uses the "nx:run-commands"-executor to run the correct compose up-command (based on the provided options) to start the application.

When using the application generator, most of these options will be pre-set based on the chosen template.

| Option | Required | Description | | ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------ | | port | Yes | Which port should be used for the (main) container application, is automatically set during the command execution. | | containerTooling | Yes | Which container-tooling to use, either "docker" or "podman". | | runAsDaemon | Yes | Whether the container application should run in daemon-mode (docker compose up -d). | | useDockerV1 | Yes | Whether to use the V2 or V1 command-syntax for docker-compose. | | envFile | No | The path to an environment file that has to be loaded before executing the command. |

stop

The stop-executor uses the "nx:run-commands"-executor to run the compose stop-command (based on the provided options) to stop the application. This executor is here because sometimes using the CTRL+C (or CMD+C on MacOS) does not always stop all containers. For instance, I've seen the Supabase Postgres database and imgproxy containers still running after cancelling the start command.

When using the application generator, most of these options will be pre-set based on the chosen template.

| Option | Required | Description | | ---------------- | -------- | ----------------------------------------------------------------------------------- | | containerTooling | Yes | Which container-tooling to use, either "docker" or "podman". | | useDockerV1 | Yes | Whether to use the V2 or V1 command-syntax for docker-compose. | | envFile | No | The path to an environment file that has to be loaded before executing the command. |

(Implicit) Dependencies

When you've generated a container application using this plugin, it is not automagically attached to your other NX projects (as we don't know in what projects it will be used). Luckily for us, NX has introduced a feature called Implicit Dependencies where you can manually link these container apps to your other NX projects.

They've thoroughly documented this functionality on their website, but for the sake of ease-of-use I'll link it here:

NX documentation for implictDependencies

Known limitations:

Sadly, there are a few things that are not quite going the way I would like them to go. I will document these limitations here, but also as issues on the GitHub-issues tab so we have a place to track progress!

The current known limitations are:

  • Cancelling the start command doesn't stop all containers: As mentioned in the stop-executor documentation, some containers seem to persist when cancelling the start-executor. The stop-executor is here not only for the daemon configuration, but also to stop all containers if simply cancelling the start-executor wasn't enough. I hope to be able to fix this in the future.
  • More templates! Right now I've only added templates for stuff I use on a (mostly) daily basis, I am however always willing to add more to the mix! So if you want support for another container application, create a feature request for this repo (or add it in a PR!).