Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Automation using Gitlab CI and Docker, DevHeaven 2018

Automation using Gitlab CI and Docker, DevHeaven 2018

Ondrej Sika

April 21, 2018
Tweet

More Decks by Ondrej Sika

Other Decks in Programming

Transcript

  1. Automation using
    Gitlab CI and Docker
    Ondrej Sika
    [email protected]
    DevHeaven,
    Pilsen CZ, 21. 4. 2018

    View full-size slide

  2. Goals
    - Build application
    - Auto deploy to test
    - Manual deploy to
    production

    View full-size slide

  3. Tools
    - Git
    - Gitlab + Gitlab CI
    - Docker
    - Traefik

    View full-size slide

  4. Setup CI environment

    View full-size slide

  5. Gitlab CI Runner
    docker-machine create runner
    eval $(docker-machine env runner)
    git clone [email protected]:ondrejsika/gitlab-ci-runner.git
    cd gitlab-ci-runner
    ./create-runner.sh
    ./register-runner.sh GITLAB_CI_TOKEN

    View full-size slide

  6. Traefik Proxy
    git clone [email protected]:ondrejsika/traefik-ssl.git
    cd traefik-ssl
    # put SSL cert.pem and key.pem to certs/ dit
    docker-compose up -d

    View full-size slide

  7. Gitlab
    - Create Gitlab project
    - Setup CI sercret variables
    - SSLPASS (password to server which runs the app)

    View full-size slide

  8. Application
    - Dockerize project
    - Add .gitlab-ci.yml (CI config)

    View full-size slide

  9. Clone Jekyll Website
    git clone [email protected]:ondrejsika/jekyll-demo.git
    cd jekyll-demo
    git remote rename origin github
    git remote add origin [email protected]:test/jekyll.git
    git push origin master -u

    View full-size slide

  10. Dockerize
    git reset --hard github/docker
    cat Dockerfile

    View full-size slide

  11. Add Gitlab CI configuration
    git reset --hard github/gitlab-ci
    cat .gitlab-ci.yml

    View full-size slide

  12. Push & some magic hapens

    View full-size slide

  13. Push
    git push origin master -u

    View full-size slide

  14. Make some changes
    git checkout -b awesome-header
    vim index.md
    git commit -am 'make header awesome'
    git push origin awesome-header -u

    View full-size slide

  15. Resources
    - https://github.com/ondrejsika/jekyll-demo
    - https://github.com/ondrejsika/traefik-ssl
    - https://github.com/ondrejsika/gitlab-ci-runner
    - https://github.com/ondrejsika/ondrejsika-ci-docker
    - https://traefik.io/

    View full-size slide

  16. Thank you & Questions
    Ondrej Sika
    email: [email protected]
    web: ondrej-sika.cz
    twitter: @ondrejsika
    linkedin: /in/ondrejsika/
    Slides: https://sika.link/devheaven2018

    View full-size slide