Mobile app version of vmapp.org
Login or Join
Murray432

: Can I host my website through gitlab like you can with github pages? I would love to use git to host my website, and would love a platform I can log into online to go along with it (something

@Murray432

Posted in: #Git #WebHosting

I would love to use git to host my website, and would love a platform I can log into online to go along with it (something like Github). You would think in which case, that Github pages would be the perfect route for me, though I don't want to use Github pages. I would like to host this all on my own servers like you do with Github enterprise (but for free).

I have found Gitlab and was wondering if there is anyway I can use Gitlab like Github pages. Is it possible?

10.05% popularity Vote Up Vote Down


Login to follow query

More posts by @Murray432

5 Comments

Sorted by latest first Latest Oldest Best

 

@XinRu657

Good News!

Since 8.3 (Dec 2015) GitLab has "GitLab Pages". about.gitlab.com/2015/12/22/gitlab-8-3-released/
This feature is available on GitLab.com (which runs EE) where you can have free, unlimited repositories, public/private.

Here is documentation for GitLab Pages, explaining how you can host for free your static websites on GitLab. doc.gitlab.com/ee/pages/README.html

10% popularity Vote Up Vote Down


 

@Berumen354

I'm not really sure what you're asking. You say you want to host on your own server but your question says you want to host like gitlab pages which is not your own server.

In any case maybe this will help

This is what I do

on local pc

mkdir folderforwebsite
cd folderforwebsite
git init
echo "hello world" > index.html
git add index.html
git commit -m "initial commit"


I now have a repo locally. Copy it to the server

scp -r ../folderforwebsite username@mydomain.com:/path/from/root/to/webfolder


Now I have it on the remote server.

ssh name@mydomain.com 'cd path/to/webfolder; git checkout -b live`


Now there's both a master and live branch on the website. I do this since AFAICT you can't push to the current branch. So now we have a "live" branch which is current on the remote and a "master" branch which is not

Finally add a remote to my local repo

git remote add web ssh://name@mydomain.com/path/from/root/to/webfolder


Now, anytime I want to update the website I check stuff into my local master branch and then run this script

#!/bin/sh
set -e
set -v
git push web master
ssh username@mydomain.com git merge --ff-only master


The git push pushes my changes to the non-current branch on the webserver. The ssh then logs into the webserver and fast-forwards the changes in "master" to the current branch. In this case the "live" branch.

--ff-only says to fail if there are changes on the server.

If there are changes on the server I can pull them into my local master with

git pull web live


On more thing. Before I do any of this I setup SSH keys on the remote server so I don't have to type any passwords

This has absolutely no connection to github or gitlab. I might push my changes there as well but they're not connected.

10% popularity Vote Up Vote Down


 

@Megan663

There is a nodejs project that implements this: github.com/Glavin001/GitLab-Pages

10% popularity Vote Up Vote Down


 

@Annie201

Currently, the best you can do is to GitLab CI to push to a static server like Amazon S3.

If you can deploy with Git, the following (unsolved) question is specific to how to do it with gitlab: stackoverflow.com/questions/14288288/gitlab-repository-mirroring
There is a specific request for that at the feature tracker: feedback.gitlab.com/forums/176466-general/suggestions/5599145-preview-render-static-html-pages-pushed-to-repos

10% popularity Vote Up Vote Down


 

@Murray432

With a little searching of various questions on Google, I found a way. It may not be the best way and it may be over complicated, but it should work and that's the main thing. Though, if you know a better way or can find one, please do let me know!

I found that you can deploy your code to your servers via Git hooks. All you need to do is SSH into your server, create a git repo and then set up a hook for you to push commits to this repo. This will allow you to push your commits to your servers, but has nothing to do with gitlab at this point.

The next step is to add the push url for gitlab to the same remote. This way, you will be pushing to both gitlab and the site itself each time. As a result, both the gitlab repo and the actual site will both be in sync. Though this is a hack and is definitely not efficient.

I found how to deploy your code to your servers via git from this blog post: sebduggan.com/blog/deploy-your-website-changes-using-git/
I found that you could add two push urls to your remotes in git from this question on stackoverflow: stackoverflow.com/questions/14290113/git-pushing-code-to-two-remotes
As I said, if you can find a better way, please do let me know. This will work, but it means having two versions of the same code. Of course, this is very messy and is a big waste of your server's storage.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme