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

vue-cli-plugin-vuedock

v2.1.0

Published

Vue CLI 3 & 4 plugin for adding dev/prod docker and compose files

Downloads

99

Readme

VueDock

Docker plugin for the Vue CLI 3 & 4

Build Status

This plugin generates the necessary docker and docker-compose files for:

  • running the local development server.
  • running eslint and unit tests
  • running e2e tests, automatically detecting cypress and nightwatch tests
  • creating a production ready image, built on top of the official nginx Docker image.

Contents

Installation

Run the following command from your project's root folder: vue add vuedock

This will generate the following files in your project root:

  • Dockerfile, multi-stage docker image used for local development and CI/Prod. Will use npm/yarn for the server and build commands depending on whether a yarn.lock file was detected when the plugin was installed
  • docker-compose.yml, compose file to be used during local development for running and testing your app. Will include extra containers for running E2E and Cypress E2E tests if these were detected when the plugin was installed.
  • .dockerignore, default ignore file

Options

Add dgoss tests

You can optionally generate a goss.yaml file ready to test your production container using goss and dgoss (a docker wrapper for goss)

When adding the plugin, you will be automatically prompted whether you want to add dgoss tests or not.

Usage

Usage in development

  1. Run Vue Application:

     # start the dev server, then navigate to http://localhost:8080 to see your app
     docker-compose up app
  2. Run ESLint:

     # Using yarn
     docker-compose run --rm app yarn lint
     # Using npm
     docker-compose run --rm app npm run lint
  3. Run Unit Tests:

     # Using yarn
     docker-compose run --rm app yarn test:unit
     # Using npm
     docker-compose run --rm app npm run test:unit
  4. Run E2E Tests (generated files support cypress and nightwatch out of the box)

     # Run tests (this will also run the app container if it wasnt already running)
     docker-compose run --rm test_e2e
     # To clean up
     docker-compose down

Usage in CI Servers

  1. Build CI ready Docker image:

     docker build --target build -t vueapp .
  2. Run linting

     # Usign yarn
     docker run --rm vueapp yarn lint
     # Using npm
     docker run --rm vueapp npm run lint
  3. Run unit test:

     # Usign yarn
     docker run --rm vueapp yarn test:unit
     # Using npm
     docker run --rm vueapp npm run test:unit
  4. Run E2E Tests (generated files support cypress and nightwatch out of the box)

     # Run tests (this will also run the app container if it wasnt already running)
     docker-compose run --rm test_e2e
     # To clean up
     docker-compose down
    • Note: You can update the E2E tests to point at any running site by changing either the CYPRESS_baseUrl or LAUNCH_URL environment variable passed into the container (dependending on whether you use cypress or nightwatch for E2E tests). That ability means that this would also be a great basis for implementing some very complex and cool delivery and rollback pipelines.
  5. Build you production image:

     docker build -t vueapp .
  6. If you enabled Dgoss test you can validate the production image with:

     docker run --rm -it \
       -v "$(pwd)":/src \
       -v /var/run/docker.sock:/var/run/docker.sock \
     iorubs/dgoss run vueapp

Usage in production

  1. Run production app built in CI server

     docker run --rm -p 8080:80 vueapp
     # Open port 8080 to see some output.

Contributing

Start by cloning this repo. Then you can develop this plugin fully in a dockerized environment or in your local environment.

Development in your local environment

  1. Copy the full path to your copy of this repo

     pwd
     # copy path like /Users/chuck/git/kaizendorks/vue-cli-plugin-vuedock
  2. Create a test app project in another folder using the Vue CLI

     vue create app
  3. Change to the new app project directory and locally install this plugin. You will need the path copied in step 1

     cd app
     npm install --save-dev file:/Users/chuck/git/kaizendorks/vue-cli-plugin-vuedock
     vue invoke vue-cli-plugin-vuedock
  4. Once invoked, undo the changes to the package.json and package-lock.json (or yarn.lock). Otherwise install would fail in docker as it wont have access to the directory where the vue-cli-plugin-vuedock plugin is located.

Development in a dockerized environment

Dockerized vue-cli

# Build image
docker build -t vuedock --target development .

# Run a shell inside the dev container
docker run --rm -it \
  -v "$(pwd)":/vuedock \
  -v /var/run/docker.sock:/var/run/docker.sock \
vuedock sh

# Create sample app
vue create app

# Change dir to project dir
cd app

# Install plugin using NPM
npm install --save-dev file:/vuedock

# Or install plugin using YARN
yarn add --dev file:/vuedock

# Run plugin
vue invoke vue-cli-plugin-vuedock

# To build and run app as normal you have to remove a line from package.json ("vue-cli-plugin-vuedock": "file:/vuedock") E.g:
docker build --target build -t vueapp .
docker run --rm vueapp yarn test:unit

CI

Goss is tool for validating server’s configuration (avoid conf. drift). Dgoss is a wrapper written on top of goss for validating docker images. https://github.com/aelsabbahy/goss/tree/master/extras/dgoss

# Build image
docker build -t vuedock .

# Dgoss Tests (quick smoke test to check if docker files were generated)
docker run --rm -it \
  -v "$(pwd)/test":/src \
  -v /var/run/docker.sock:/var/run/docker.sock \
iorubs/dgoss run vuedock

# Edit tests
docker run --rm -it \
  -v "$(pwd)/test":/src \
  -v /var/run/docker.sock:/var/run/docker.sock \
iorubs/dgoss edit vuedock

# Build generated dockerfiles
docker run --rm -it \
  -v /var/run/docker.sock:/var/run/docker.sock \
vuedock docker build --target build -t vueapp .

# Run default Vue unit tests
docker run --rm vueapp yarn test:unit

# Try building prod container
docker run --rm -it \
  -v /var/run/docker.sock:/var/run/docker.sock \
vuedock docker build -t app .

# Run prod app dgoss tests
docker run --rm -it \
  -v "$(pwd)/generator/template/dgoss":/src \
  -v /var/run/docker.sock:/var/run/docker.sock \
iorubs/dgoss run app

# Edit prod app dgoss tests
docker run --rm -it \
  -v "$(pwd)/generator/template/dgoss":/src \
  -v /var/run/docker.sock:/var/run/docker.sock \
iorubs/dgoss edit app