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 Slide

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

    View Slide

  3. View Slide

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

    View Slide

  5. Setup CI environment

    View Slide

  6. 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 Slide

  7. Server

    View Slide

  8. 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 Slide

  9. Gitlab

    View Slide

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

    View Slide

  11. Application

    View Slide

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

    View Slide

  13. 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 Slide

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

    View Slide

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

    View Slide

  16. Push & some magic hapens

    View Slide

  17. Push
    git push origin master -u

    View Slide

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

    View Slide

  19. 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 Slide

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

    View Slide