0.0.5 • Published 5 months ago

vite-plugin-docker v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Docker Plugin for Vite.js

This is a Vite.js plugin that facilitates integration with Docker for building and running containers.

Motivation

The motivation behind using this plugin is to streamline the development environment by creating isolated standalone environments for each developer. This allows developers to work in a consistent and reproducible environment, minimizing potential conflicts and ensuring a smoother development experience.

Installation

npm install --save-dev plugin-docker

Usage

In your vite.config.js file, import the plugin and add it to the plugins section:

import { defineConfig } from "vite";
import pluginDocker from "plugin-docker";
export default defineConfig({
  plugins: [
    pluginDocker([
      // ...Docker configurations here
    ]),
  ],
});

Configuration

Attributes of PluginDockerOptions

AttributeDescription
nameName of the Docker container.
dockerfilePath to the Dockerfile for building the image.
enabled(Optional) Enable or disable the plugin. Default value: true.
profile(Optional) Image build profile.
imageTag(Optional) Docker image tag.
imageIncludes(Optional) Files included in the Docker image.
envPrefix(Optional) Prefixes to be applied to environment variables during Docker container operations.
envOverride(Optional) Overrides for specific environment variables during Docker container operations.
startActions(Optional) Actions to perform when the dev/start project is initialized.
buildStartActions(Optional) Actions to perform when the build process is started.
buildEndActions(Optional) Actions to perform when the build process is completed.
dockerOptions(Optional) Additional Docker options.
actionOptions(Optional) Action options for customizing Docker actions.
hotReload(Optional) Enable or disable hot reload. Default value: false.

Example 1

import { defineConfig } from "vite";
import pluginDocker from "plugin-docker";
export default defineConfig({
  plugins: [
    pluginDocker({
      name: "NGinx",
      dockerfile: "NGinx.Dockerfile",
      actionOptions: {
        onContainerCreateOptions: (opts) => {
          return {
            ...opts,
            ExposedPorts: { "80/tcp": {} },
            HostConfig: {
              PortBindings: { "80/tcp": [{ HostPort: "8080" }] },
            },
          };
        },
      },
      startActions: ["image:build", "container:create", "container:start"],
    }),
  ],
});

Example 2

import { defineConfig } from "vite";
import pluginDocker from "plugin-docker";
export default defineConfig({
  plugins: [
    pluginDocker({
      name: "MongoV1",
      imageTag: "mongo",
      actionOptions: {
        onContainerCreateOptions: (opts) => {
          return {
            ...opts,
            ExposedPorts: { "27017/tcp": {} },
            HostConfig: {
              PortBindings: { "27017/tcp": [{ HostPort: "27017" }] },
            },
          };
        },
      },
      startActions: ["container:create", "container:start"],
    }),
  ],
});

Example 3

import { defineConfig } from "vite";
import pluginDocker from "plugin-docker";
export default defineConfig({
  plugins: [
    pluginDocker([
      {
        // MONGO
      },
      {
        // NGINX
      },
      // Other containers...
    ]),
  ],
});
0.0.5

5 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago