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.04Prerequisites
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:
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
<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.
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
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
SSH into your server by running:
ssh [email protected]<server-ip>
Install GitLab Runner
NOTE: SSH procedure may be different on windows
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/):
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
To skip all these procedures, you can directly visit
<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:
Please enter the gitlab-ci tags for this runner (comma separated):
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:
shell and press enter. At this point, you have successfully registered a GitLab Runner on your server.
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:
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] ...
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
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.
Select a branch to deploy from, by default it will be
master. Click on
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.
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
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 2vue-svg-transition
Create 2-state, SVG-powered animated icons.Vue-Awesome
Awesome SVG icon component for Vue.js, with built-in Font Awesome icons.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.vue-zondicons
Easily add Zondicon icons to your vue web project.vicon
Vicon is an simple iconfont componenet for vue.
iconfont is a Vector Icon Management & Communication Platform made by Alimama MUX.
A tool to create svg icon components. (vue 2.x)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.vue-ionicons
Vue Icon Set Components from Ionic Team
Design Icons, sourced from the Ionicons project.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.
I hope you like them!
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.showdown-markdown-editor
A markdown editor using codemirror and previewer using showdown for Vue.js.markdown-it-vue
The vue lib for markdown-it.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.v-markdown-editor
Vue.js Markdown Editor component.markdown-to-vue-loader
Markdown to Vue component loader for Webpack.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.
Markdown Editor component for Vue.js. Support both vue1.0 & vue2.0mavonEditor
A nice vue.js markdown editor. Support WYSIWYG editing mode, reading mode and so on.vue-markdown
A Powerful and Highspeed Markdown Parser for Vue.
Thank for read!
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
A vue component that wraps a input type=number with a customizable range slider flyout with 2-way binding.
International Telephone Input with Vue.
Allow restricted character sets in input elements.
The Vue Currency Input plugin allows an easy input of currency formatted numbers.
Input components for vue.js.
Simple example of issue I am seeing with input labels.
A Vue.js wrapper for Zurb's Tribute library for native @mentions.
Number input with rich functionality for Vue.js.
Super tiny input mask library for vue.js based on PureMask.js (~2kb) exposed as directive. No dependencies.
mask directive for vue.js
An ip address input with port and material design support.
Tiny input/directive mask for currency
Dead simple masked input component for Vue.js 2.X. Based on inputmask-core.
Mobile & Desktop friendly VueJS input component
I hope you like them!