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:

Rust logo over black marble background.

Handling memory leaks in Rust

Learn how to manage memory leaks in Rust, avoid unsafe behavior, and use tools like weak references to ensure efficient programs.

Ukeje Goodness
Nov 20, 2024 â‹… 4 min read
Robot pretending to be a person.

Using curl-impersonate in Node.js to avoid blocks

Bypass anti-bot measures in Node.js with curl-impersonate. Learn how it mimics browsers to overcome bot detection for web scraping.

Antonello Zanini
Nov 20, 2024 â‹… 13 min read
Solving Eventual Consistency In Frontend

Solving eventual consistency in frontend

Handle frontend data discrepancies with eventual consistency using WebSockets, Docker Compose, and practical code examples.

Kayode Adeniyi
Nov 19, 2024 â‹… 6 min read
How To Use Lazy Initialization Pattern With Rust 1.80

How to use the lazy initialization pattern with Rust 1.80

Efficient initializing is crucial to smooth-running websites. One way to optimize that process is through lazy initialization in Rust 1.80.

Yashodhan Joshi
Nov 18, 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