Using GitLab CI/CD to auto-deploy your Vue.js Application

Using GitLab CI/CD to auto-deploy your Vue.js Application

Using GitLab CI/CD to auto-deploy your Vue.js Application, we'll create a Vue project, wrote Docker and GitLab CI configurations, configure a server with Docker, GitLab Runner (along with necessary permissions), and configure a pipeline on GitLab. How to auto deploy a Vue application using GitLab CI/CD on Ubuntu 18.04

Prerequisites
  • Basic knowledge of the command line
  • Basic knowledge of Docker
  • Basic knowledge of version control
  • Latest release of node installed on your local machine
Install Vue on your local machine

First, you will be installing vue-cli. It is a command-line tool that enables you to quickly scaffold a new Vue application. Run the following command to install vue-cli on your local machine:

npm install -g @vue/cli

This will pull all the dependencies required to run vue-cli, you can verify its installation by running:

vue

Create a Vue application

In this step, you will be creating a new app using the vue-cli create command which will help us scaffold our application along with necessary plugins. Run the following to create a new Vue application:

vue create vue-demo

You will be prompted to select a preset, leave it at the default preset, and press enter to continue.


When this is done, change directory into the vue-demo folder created by the vue-cli and run:

npm run serve

This will make your Vue application accessible on localhost via port 8080. Visit http://localhost:8080 to view your application.

Set up GitLab

Now, you will be pushing your Vue application to a GitLab repository. Head over to GitLab’s Website and log into your account or create an account if you do not have one already.

Next, create a new project. At the top right corner of your GitLab dashboard, you will see a green button with the text New project. Click on it.

A new screen will come up asking you to give a name to the project. Name the project vue-demo, you can leave the project description empty, it can be either a public or private repository. Leave the last checkbox unticked.

You need to associate your vue-demo application locally with the remote repository. To do that, head over to the terminal and make sure you are in the application’s directory and run the following:

git init
git remote add origin [email protected]:<your-gitlab-username>/vue-demo.git
git add .
git commit -m "Initial commit"
git push -u origin master

NOTE: Replace <your-gitlab-username> with your actual GitLab username.

You will be prompted to input your GitLab password or authenticate via SSH if you have previously configured that in the past. When done, visit vue-demo project dashboard on Gitlab, all your source files should be present.

Configure the pipeline

In this step, we will be configuring our pipeline using Docker and GitLab CI. Using your preferred text editor or IDE, create a new file named Dockerfile without any extension and paste the following:

FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

This Docker configuration pulls the Node alpine image which will be used to build our application for production and the second stage pulls the Nginx alpine image which will be used to serve our build codebase copied from the first stage.

Next, create a .gitlab-ci.yml. This will allow GitLab to deploy our changes to the server. This config file creates a communication to the server. It contains operations and commands that should be executed on the server on every code push. Copy and save the following into your .gitlab-ci.yml file:

image: docker
services:
  - docker:dind
stages:
  - deploy
step-deploy-prod:
  stage: deploy
  script:
    - docker build -t app/vue-demo .
    - docker run -d -p 80:80 --rm --name todoapp app/vue-demo

Commit and push these files to the remote repository:

git add .
git commit -m "Pipeline Configurations"
git push

In the next step, we will be configuring our server to work with GitLab’s CI/CD.

Configure the server

In this step, you will be needing a server running Ubuntu. You can sign up on DigitalOcean and quickly provision Ubuntu server.

SSH into your server

SSH into your server by running:

ssh [email protected]<server-ip>

NOTE: SSH procedure may be different on windows

Install GitLab Runner

GitLab Runner acts as the interface between GitLab and your remote server. Run the following to install GitLab Runner:

curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt-get install gitlab-runner
sudo gitlab-runner start

This will install and start GitLab Runner on your server.

Register a pipeline

To register a pipeline, run the following command:

sudo gitlab-runner register

You will be returned a prompt like this:

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):

Type https://gitlab.com/ and press Enter. The next prompt will be:

Please enter the gitlab-ci token for this runner:

You can get your token from your vue-demo project dashboard by hovering on Settings on the navigator section on the left, another sub-menu will show up with a bunch of options, click on CI / CD.

Next, click on the Expand button on the runner’s option.

You will see your token after the option is expanded, copy it, go back to your server SSH terminal, paste it and press the Enter key.

To skip all these procedures, you can directly visit https://gitlab.com/<username>/vue-demo/-/settings/ci_cd.

NOTE:<username>should be your gitlab username

Next, you will be asked to enter a description and tags for the runner like this:

Please enter the gitlab-ci description for this runner:

and

Please enter the gitlab-ci tags for this runner (comma separated):

Press the Enter key to skip these. Next, you will be prompted with the following:

Please enter the executor: ssh, virtualbox, kubernetes, docker, docker-ssh, shell, docker+machine, docker-ssh+machine, custom, parallels:

Type in shell and press enter. At this point, you have successfully registered a GitLab Runner on your server.

Install Docker

You can quickly install docker by running:

sudo snap install docker

This will quickly install Docker on your machine. Next, we need to set permissions for Docker by running:

sudo groupadd docker
sudo usermod -aG docker $USER

Reboot your server like this:

reboot

Log back in and run:

sudo usermod -aG docker gitlab-runner

This will add GitLab Runner to the Docker group.

Add GitLab Runner to sudoers

To add GitLab Runner to the list of sudoers, run:

sudo nano /etc/sudoers

Paste the following at the end of the file:

gitlab-runner ALL=(ALL) NOPASSWD: ALL

Save and exit nano.

Verify information

To verify your information run:

sudo nano /etc/gitlab-runner/config.toml

It should contain contents like this:

...
[[runners]]
  url = "https://gitlab.com/"
  token = "XXXXXXXXX"
  executor = "shell"
  [runners.custom_build_dir]
  [runners.ssh]
    user = "<SERVER ACCOUNT USERNAME>"
    host = "<SERVER IP ADDRESS>"
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
...

If the user and host attribute details do not match that of your server, you can correct it in this section:

...
[runners.ssh]
  user = "<SERVER ACCOUNT USERNAME>"
  host = "<SERVER IP ADDRESS>"
...

If it’s not present in the file, add it along with the right credentials, save and exit the file. Restart GitLab Runner:

sudo gitlab-runner restart
Test deployment

In this step, you will be running your pipeline to see if your application will deploy on the server.

Head over to the pipeline menu from your project GitLab’s dashboard.

Click on Run Pipeline.

Select a branch to deploy from, by default it will be master. Click on Run Pipeline.

Your application deployment will begin.

Click on the step-deploy-.... button to see the process.

Once deployment succeeds, you will see a Job succeeded message. If it fails, review all the steps to make sure you did not miss anything. Visit your server IP address on your browser, you will see the Vue landing page, which means your application was deployed successfully.

Your application will build and deploy itself on every push made to the master branch automatically.

Conclusion

In this tutorial, you successfully created a Vue project, wrote Docker and GitLab CI configurations, configured a server with Docker, GitLab Runner (along with necessary permissions), and configured a pipeline on GitLab. With this, you are set to configure other projects in the future.

Originally published by Michael Okoh at https://blog.logrocket.com

10 Best Vue Icon Component For Your Vue.js App

10 Best Vue Icon Component For Your Vue.js App

In this article, I will collect 10 Vue icon component to bring more interactivity, better UI design to your Vue application.

Icons are the vital element of the user interface of the product enabling successful and effective interaction with it. In this article, I will collect 10 Vue icon component to bring more interactivity, better UI design to your Vue application.

1. Animated SweetAlert Icons for Vue

A clean and simple Vue wrapper for SweetAlert's fantastic status icons. This wrapper is intended for users who are interested in just the icons. For the standard SweetAlert modal with all of its bells and whistles, you should probably use Vue-SweetAlert 2

Demo: https://vue-sweetalert-icons.netlify.com/

Download: https://github.com/JorgenVatle/vue-sweetalert-icons/archive/master.zip

2. vue-svg-transition

Create 2-state, SVG-powered animated icons.

Demo: https://codesandbox.io/s/6v20q76xwr

Download: https://github.com/kai-oswald/vue-svg-transition/archive/master.zip

3. Vue-Awesome

Awesome SVG icon component for Vue.js, with built-in Font Awesome icons.

Demo: https://justineo.github.io/vue-awesome/demo/

Download: https://github.com/Justineo/vue-awesome/archive/master.zip

4. vue-transitioning-result-icon

Transitioning Result Icon for Vue.js

A scalable result icon (SVG) that transitions the state change, that is the SVG shape change is transitioned as well as the color. Demonstration can be found here.

A transitioning (color and SVG) result icon (error or success) for Vue.

Demo: https://transitioning-result-icon.dexmo-hq.com/

Download: https://github.com/dexmo007/vue-transitioning-result-icon/archive/master.zip

5. vue-zondicons

Easily add Zondicon icons to your vue web project.

Demo: http://www.zondicons.com/icons.html

Download: https://github.com/TerryMooreII/vue-zondicons/archive/master.zip

6. vicon

Vicon is an simple iconfont componenet for vue.

iconfont
iconfont is a Vector Icon Management & Communication Platform made by Alimama MUX.

Download: https://github.com/Lt0/vicon/archive/master.zip

7. vue-svgicon

A tool to create svg icon components. (vue 2.x)

Demo: https://mmf-fe.github.io/vue-svgicon/v3/

Download: https://github.com/MMF-FE/vue-svgicon/archive/master.zip

8. vue-material-design-icons

This library is a collection of Vue single-file components to render Material Design Icons, sourced from the MaterialDesign project. It also includes some CSS that helps make the scaling of the icons a little easier.

Demo: https://gitlab.com/robcresswell/vue-material-design-icons

Download: https://gitlab.com/robcresswell/vue-material-design-icons/tree/master

9. vue-ionicons

Vue Icon Set Components from Ionic Team

Design Icons, sourced from the Ionicons project.

Demo: https://mazipan.github.io/vue-ionicons/

Download: https://github.com/mazipan/vue-ionicons/archive/master.zip

10. vue-ico

Dead easy, Google Material Icons for Vue.

This package's aim is to get icons into your Vue.js project as quick as possible, at the cost of all the bells and whistles.

Demo: https://material.io/resources/icons/?style=baseline

Download: https://github.com/paulcollett/vue-ico/archive/master.zip

I hope you like them!

Collection of 10 Vue Markdown Component for Vue.js App in 2020

Collection of 10 Vue Markdown Component for Vue.js App in 2020

Markdown is a way to style text on the web. The 10 Vue markdown components below will give you a clear view.

Markdown is a way to style text on the web. You control the display of the document; formatting words as bold or italic, adding images, and creating lists are just a few of the things we can do with Markdown.

The 10 Vue markdown components below will give you a clear view.

1. Vue Showdown

Use showdown as a Vue component.

View Demo

Download Source

2. showdown-markdown-editor

A markdown editor using codemirror and previewer using showdown for Vue.js.

View Demo

Download Source

3. markdown-it-vue

The vue lib for markdown-it.

View Demo

Download Source

4. perfect-markdown

perfect-markdown is a markdown editor based on Vue & markdown-it. The core is inspired by the implementation of mavonEditor, so perfect-markdown has almost all of the functions of mavonEditor. What's more, perfect-markdown also extends some features based on mavonEditor.

View Demo

Download Source

5. v-markdown-editor

Vue.js Markdown Editor component.

View Demo

Download Source

6. markdown-to-vue-loader

Markdown to Vue component loader for Webpack.

View Demo

Download Source

7. fo-markdown-note Component for Vue.js

fo-markdown-note is a Vue.js component that provides a simple Markdown editor that can be included in your Vue.js project.

fo-markdown-note is a thin Vue.js wrapper around the SimpleMDE Markdown editor JavaScript control.

View Demo

Download Source

8. Vue-SimpleMDE

Markdown Editor component for Vue.js. Support both vue1.0 & vue2.0

View Demo

Download Source

9. mavonEditor

A nice vue.js markdown editor. Support WYSIWYG editing mode, reading mode and so on.

View Demo

Download Source

10. vue-markdown

A Powerful and Highspeed Markdown Parser for Vue.

View Demo

Download Source

Thank for read!

Collection of 15 Vue Input Component for Your Vue.js App

Collection of 15 Vue Input Component for Your Vue.js App

Vue input component gives you a baseline to create your own custom inputs. It consists of a prepend/append slot, messages, and a default slot. In this article I will share 15 Vue input components to you.

Vue input component gives you a baseline to create your own custom inputs. It consists of a prepend/append slot, messages, and a default slot. In this article I will share 15 Vue input components to you.

1. Maska
  • No dependencies
  • Small size (~2 Kb gziped)
  • Ability to define custom tokens
  • Supports repeat symbols and dynamic masks
  • Works on any input (custom or native)

Demo

Download


2. v-range-flyout

A vue component that wraps a input type=number with a customizable range slider flyout with 2-way binding.

Demo

Download


3. vue-tel-input

International Telephone Input with Vue.

Demo

Download


4. Restricted Input

Allow restricted character sets in input elements.

Features

  • Disallow arbitrary characters based on patterns
  • Maintains caret position
  • Format/Update on paste
  • Works in IE11+

Demo

Download


5. Vue Currency Input

The Vue Currency Input plugin allows an easy input of currency formatted numbers.

Demo

Download


6. vue-fields

Input components for vue.js.

Demo

Download


7. vue-material-input

Simple example of issue I am seeing with input labels.

Demo

Download


8. vue-tribute

A Vue.js wrapper for Zurb's Tribute library for native @mentions.

Demo

Download


9. vue-number-smarty

Number input with rich functionality for Vue.js.

Features

  • integer/float
  • signed/unsigned
  • step size
  • increment/decrement value by scrolling when focused
  • align variants
  • min and max boundaries
  • max length of integer part (only for float type)
  • max length of float part (only for float type)
  • max length of string
  • error state
  • readonly state
  • theme options

Demo

Download


10. Vue input mask

Super tiny input mask library for vue.js based on PureMask.js (~2kb) exposed as directive. No dependencies.

Demo

Download


11. vue-r-mask

mask directive for vue.js

  • Template similar to javascript regular expression. /\d{2}/
  • Directive useful for your own input or textarea.
  • Arbitrary number of digits in template /\d{1,10}/

Demo

Download


12. Vue IP

An ip address input with port and material design support.

Demo

Download


13. v-money Mask for Vue.js

Tiny input/directive mask for currency

Features

  • Lightweight (<2KB gzipped)
  • Dependency free
  • Mobile support
  • Component or Directive flavors
  • Accept copy/paste
  • Editable

Demo

Download


14. Vue Masked Input

Dead simple masked input component for Vue.js 2.X. Based on inputmask-core.

Demo

Download


15. VueJS input component

Mobile & Desktop friendly VueJS input component
Features used
CSS variables
Vue's transition-group
Flexbox

Demo


I hope you like them!