Workshop on GitLab
sudo docker pull gitlab/gitlab-ce:latest
sudo docker run --detach \
--hostname dockerhost.example.com \
--publish 30443:443 --publish 30080:80 --publish 30022:22 \
--name gitlab \
--restart always \
--volume /srv/gitlab/config:/etc/gitlab \
--volume /srv/gitlab/logs:/var/log/gitlab \
--volume /srv/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
login ip:30080 and change root password
เพิ่ม user ในระบบ
Add ssh key in profile
Create project
project information
Git Command line
git config --global user.name "sawangpong"
git config --global user.email "[email protected]"
create new repo
git clone http://dockerhost.example.com/sawangpong/taladdee.git
cd taladdee
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin
http://dockerhost.example.com/sawangpong/taladdee.git
git add .
git commit -m "Initial commit"
git push -u origin master
Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin http://dockerhost.example.com/sawangpong/taladdee.git
git push -u origin --all
git push -u origin --tags
Create CI/CD
What is .gitlab-ci.yml
The .gitlab-ci.yml file is where you configure what CI does with your project. It lives in the root of your repository. On any push to your repository, GitLab will look for the .gitlab-ci.yml file and start jobs on Runners according to the contents of the file,
for that commit.
สร้าง file
เราต้องทำการสร้างไฟล์ .gitlab-ci.yml ขึ้นมาใน Root Path โปรเจคของเรา ซึ่งไฟล์นี้จะทำหน้าที่ประมวลผลตามที่เราต้องการ
git add .gitlab-ci.yml
git commit -m "Add .gitlab-ci.yml"
git push origin master
go to pineline
Delete project
Go to Settings > Expand Advanced Settings >Remove Projectclick expand
1 Create Docker file
FROM php:5.6-apache
ADD . /var/www/html
RUN docker-php-ext-install -j$(nproc) mysql && a2enmod rewrite
2 Create gitlab-ci.yml
build_image:
image: docker:git
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/[YOUR ORG]/[YOUR REPO] .
- docker push registry.gitlab.com/[YOUR ORG]/[YOUR REPO]:latest
only:
- master
replace [YOUR ORG]/[YOUR REPO]
keep $CI_BUILD_TOKEN
What this configuration instructs Gitlab to is to use a default git container as a basis for building the project and to load the Docker in Docker service (docker:dind). Docker in Docker is a service needed to build Docker containers from within a Docker container since Gitlab CI uses Docker Containers itself to run from.