2020-01-19
1356
#vue
Michael Okoh
12737
Jan 19, 2020 â‹… 4 min read

How to auto deploy a Vue application using GitLab CI/CD on Ubuntu 18.04

Michael Okoh I code, that's all.

Recent posts:

Using React Shepherd To Build A Site Tour

Using React Shepherd to build a site tour

React Shepherd stands out as a site tour library due to its elegant UI and out-of-the-box, easy-to-use React Context implementation.

Onuorah Bonaventure
May 1, 2024 â‹… 14 min read
A Guide To Cookies In Next Js

A guide to cookies in Next.js

Cookies are crucial to web development. This article will explore how to handle cookies in your Next.js applications.

Georgey V B
Apr 30, 2024 â‹… 10 min read
Handling Dates In JavaScript With Tempo

Handling dates in JavaScript with Tempo

Use the Tempo library to format dates and times in JavaScript while accounting for time zones, daylight saying time, and date internationalization.

Amazing Enyichi Agu
Apr 30, 2024 â‹… 8 min read
A Guide To Deno.cron

A guide to Deno.cron

This guide explores how to use the cron package in Deno, `Deno.cron`, to handle scheduling tasks with specific commands.

Rosario De Chiara
Apr 29, 2024 â‹… 5 min read
View all posts

7 Replies to "How to auto deploy a Vue application using GitLab CI/CD on Ubuntu 18.04"

  1. Hi, thanks for this great article, I just would to ask, can I using shared runner for this deployment? thanks

  2. I think you must to install but I am not so sure becouse docker is supposed to run on your machine (Server)

  3. Right now I am working on it and I could you tell you the answer is NO.

    Shared Runners are running on some a machine/server that you cannot login. To make it possible for us to use any kinds of runner, here is my idea.

    First we need to figure it out how a runner, an executor and the server where we deploy our applications interact with each others.

    * A Runner is a program that executes your scripts(including before_script and after_script) in a gitlab job,
    * The executor of a runner could be “shel”l, “docker”, “docker+machine”, and so on. (refer to gitlab doc) Shared Runners use a stragety “docker+machine” as their executors, and the machine running the shared runners is beyond our control.
    * The deployment server is exactly where you deploy your service( could be in form of docker container). Usually we can have our own server from AWS, Google Cloud Service and Azure and so on. It is under our control and we can login with certain credentials.

    The reason why the article above works, is the runner is runnning on the deployment server. The runner start a docker container and the container maps its port to the server’s port and finally it is open to public. The cost is you have to manually set up gitlab runner on your deployment server, which demands some amount of hardware resources.

    Is there any way to separate gitlab runners and the deployment server?

    If yes, then we can use any runner to do the deployment. However, in this case, obviously, the runner has to be able to execute commands in the server which require login. We can set up environment variables to store credentials and feed it to ssh/sshpass command in the scirpt. As far as I know from the Internet, there are two methods to automate login. 1. Copy the private key of your server to the variables and write it to .ssh/known_hosts in your script. 2. create a new user with necessary permission and give username and password to the runner via environment variables.

    I don’t think at any time we should leak out the private key, so I am trying to make it in method 2. However, SSH doesn’t allow password provided from terminal so I use sshpass to wrap it, while sshpass results in a new problem that return error code 6 (If you are interested, you can dig it out later). Right now I am working on this problem. The reason is clear and I am working on it. Hopefully I can overcome any sequential problems…

  4. First of all thanks Michael, I could run all these process and test the image and container on local pc and get result
    But as server side, even though I could run pipeline and get ‘Job succeeded’ on gitlab area, couldnt get any result or change on server. How can I check created container or image on server? Both image and container work well on my pc but I have no output of them on server. I use Ubuntu server and even created and tested all these process on server manually and step by step and could load project as localhost in server but as I said the deploy with gitlab hasnt any result

  5. same issue.
    solution was create folder nginx in “vue-demo” repository –> “nginx/main.conf” and disable public in Settings -> CI/CD –> Runners, find your runner and disable Shared Runners parameter

  6. Thanks for the tutorial, its quite a long way. I needed to disable: gitlab-settings-ci/cd shared Runners to get it work

Leave a Reply