Gitlab installation, automatic deployment of laravel project

Time:2020-9-29

Gitlab installation

Using docker to install gitlab

1:docker pull gitlab/gitlab-ce
2:docker run -d  -p 4438:443 -p 8088:80 -p 2228:22 --name gitlab --restart always -v /home/gitlab/config:/etc/gitlab -v /home/gitlab/logs:/var/log/gitlab -v /home/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce
3:/var/opt/gitlab/gitlab-rails/etc/ gitlab.yml  Modify the file host in the container
4: Gitlab CTL restart

Installing gitlab runner on the host computer and using docker to install gitlab runner has made a lot of trouble because the physical server in the intranet cannot be accessed locally

SSH password free login
//Switch to gitlab runner
su gitlab-runner
//Generating public and private keys
ssh-keygen
//The public key of the local host is copied to the authorized of the remote host_ On the keys file,
ssh-copy-id -i /home/gitlab-runner/.ssh/id_ rsa.pub  [email protected]  (172.17.0.1 host IP, docker network IP; IP addr)

The laravel project builds YML files automatically

    stages:
  - develop

develop:
  stage: develop
  cache:
    paths:
      - vendor/
  tags:
    - develop
  script:
    - composer install
    - cp .env.example .env
    - php artisan key:generate
    - php artisan migrate
    - rsync -arvp -e "ssh" --rsync-path="sudo rsync" --delete-before . [email protected]:/xxx/xxxx/blog/
    - ssh [email protected]  "cd /xxx/xxx/blog && php artisan config:cache && supervisorctl restart all"
  only:
    - develop
  • php artisan config:cache // This command should be put after code synchronization, otherwise the configuration file will be cached, resulting in inconsistent paths
  • If a queue task is managed by supervisor, it needs to be restarted

Recommended Today

(2) start with mybatis

Prospect review In the MVP version, we have implemented a basic running mybatis. As the saying goes, everything is difficult at the beginning, then difficult in the middle. The plug-in mechanism of mybatis is the second soul besides dynamic proxy. Let’s experience the pain and happiness of this interesting soul~ The role of plug-ins In […]