diff --git a/content/docker.md b/content/docker.md new file mode 100644 index 0000000000000000000000000000000000000000..effa6861bc05918b37a029e9b228b942463a7de7 --- /dev/null +++ b/content/docker.md @@ -0,0 +1,42 @@ +## Docker + +Download and modify a Docker image: + +``` +docker images +docker run -t -i ruby:2.3 /bin/bash + +$ apt-get update +$ apt-get install nodejs -y +$ gem install bundler --no-ri --no-rdoc +# A Dockerfile is a great option for the following line or +# maybe integrate with our current CI script? +$ bundle install +$ exit + +# Log back in? +docker ps -a # and get container sha +docker start -i <container-sha> +``` + +---------- +## Create a custom image + +``` +# Commit a new image +docker commit -m "Adds dependencies" -a "Peter Parker" \ +<container-sha> registry.gitlab.com/<group-name>/projectname:v2 + +# Or commit the image and tag it later +docker tag <image id> <url>:<port>/<user/project>:<tag> + +# Login in to GitLab registry +# docker login registry.gitlab.com +docker login <url>:<port> + +# Push image to registry +# docker push registry.gitlab.com/gitlab-org/ci-training-sample +docker push <registry-url>/<group-name>/<project-name>:<tag> +``` + +[Back](#/agenda) diff --git a/content/gitlab-ci-yml.md b/content/gitlab-ci-yml.md index e461dbef34f3156350c470d9ad7e9b0d76ed2bd5..17a7a04f0ebbe572cf6fc88ba3a31762e3623080 100644 --- a/content/gitlab-ci-yml.md +++ b/content/gitlab-ci-yml.md @@ -1,17 +1,165 @@ -## Configurations: gitlab-ci.yml +## Configurations: gitlab-ci.yml -- Choose a directory on you machine easy to access -- Create a workspace or development directory -- This is where we'll be working and adding content +---------- + +### Let's start building the app + +- What is the `gitlab-ci.yml` file? +- Review the file with CI Lint at Pipelines +- Our plan: + - Image + - Services + - Environments + - Stages + - Jobs +---------- + - Before and After Scripts + - Caching + - Artifacts & On Success + - Only and except + - When + - Pages + +---------- + +### Docker Image & Registry + +Use a public image: +``` +image: ruby:2.3 +``` +Use a custom image: +``` +image: "registry.gitlab.com/gitlab-org/ci-training-sample:ruby-and-gems" +``` + +---------- + +### Services and Variables + +- Pre defined vars: https://docs.gitlab.com/ce/ci/variables/README.html + +``` +services: + - postgres + +variables: + POSTGRES_DB: rails-sample-1_test + POSTGRES_USER: root + POSTGRES_PASSWORD: "" +``` +---------- + +### Stages + +- Default stages: build, test, deploy +- User can define any custom stage and any number of jobs per stage + +``` +stages: +- build +- test +- deploy +``` +---------- + +### Before and After Scripts + +``` +before_script: + - echo CI_BUILD_STAGE + - apt-get update + - apt-get install nodejs -y + - gem install bundler --no-ri --no-rdoc + - bundle install +``` +---------- + +### Caching + +``` +cache: + key: "%CI_BUILD_STAGE%/%CI_BUILD_REF_NAME%" + paths: + - vendor/ruby +``` + +---------- + +### Templates +- Anchors, aliases and merging with yml + +``` +.hidden_anchor: &ruby_info + script: + - echo ruby -v + - echo which ruby + +env_info: + <<: *ruby_info + stage: build +``` + +---------- + +### Artifacts & On Success + +``` +system_specs: + stage: build + script: + - echo "author:" + - echo GITLAB_USER_EMAIL + - touch system_info + - uname -a > system_info + artifacts: + when: on_success + paths: + - system_info +``` ---------- +### Tests and Manual trigger + +``` +rspec: + stage: test + when: manual + script: + - "sed -i 's/host:.*/host: postgres/g' config/database.yml" + - "sed -i 's/username:.*/username: root/g' config/database.yml" + - bundle exec rake db:migrate RAILS_ENV=test + - bundle exec rake spec ``` -mkdir ~/development -cd ~/development --or- +---------- + +### Environments, Only and Deploying -mkdir ~/workspace -cd ~/workspace +``` +pseudo-deploy: + stage: deploy + script: + - echo "Deploying ... not really" + only: + - production + environment: + name: production +``` + +---------- + +### Pages + +``` +pages: + stage: deploy + script: + - echo 'Publishing pages' + artifacts: + paths: + - public + only: + - master ``` diff --git a/content/runners.md b/content/runners.md index 82db0322d117121ceed4f604c757c05c20ee96c0..f6c7eb5da0bd011ee485cc4663327f938ae560ca 100644 --- a/content/runners.md +++ b/content/runners.md @@ -1,17 +1,14 @@ ## Runners -- Choose a directory on you machine easy to access -- Create a workspace or development directory -- This is where we'll be working and adding content +- A runner is an isolated (virtual) machine that picks up builds through the +coordinator API of GitLab CI. ----------- +- You can create as many Runners as you need on different machines -``` -mkdir ~/development -cd ~/development +- The Runners screen --or- +- Specific vs Shared Runners -mkdir ~/workspace -cd ~/workspace -``` +- Installation vs registration + +- Tagged Runners diff --git a/content/sample_app.md b/content/sample_app.md index 3c55fd091ad8ad9de8ce8352bfe2e97a5fa5c16a..8e819743146facbdf7e30fa1397aaf90debaf132 100644 --- a/content/sample_app.md +++ b/content/sample_app.md @@ -1,44 +1,28 @@ ## Sample App - ---------- -## Docker - -Download and modify a Docker image: +### Main Objectives +- Build a web application on Ruby on Rails +- Create an integration workflow +- Automate deployments -``` -docker images -docker run -t -i ruby:2.3 /bin/bash +--- -$ apt-get update -$ apt-get install nodejs -y -$ gem install bundler --no-ri --no-rdoc -# A Dockerfile is a great option for the following line or -# maybe integrate with our current CI script? -$ bundle install -$ exit +### Complementary +- Project landing page +- Docker environment for build and development -# Log back in? -docker ps -a # and get container sha -docker start -i <container-sha> -``` +Note: +- Add some interesting context such as "we're getting hired to do ABC" ---------- -## Create a custom image - -docker tag <image id> <url>:<port>/<user/project>:<tag> - -``` -# Commit a new image -docker commit -m "Adds dependencies" -a "Peter Parker" \ -<container-sha> registry.gitlab.com/<group-name>/projectname:v2 -# Login in to GitLab registry -# docker login registry.gitlab.com -docker login <url>:<port> +### App and CI Tour -# Push image to registry -# docker push registry.gitlab.com/gitlab-org/ci-training-sample -docker push <registry-url>/<group-name>/<project-name>:<tag> -``` +- Review files and repository +- View CI badge +- Talk about the pipeline and builds +- Talk about environments +- Cycle Analytics +- Activating builds diff --git a/index.html b/index.html index 97a1ee69ff314d182e5b96fcf142274c8d52eba0..a74db99717f9d77a315e04a9a073f6f8a7bec697 100644 --- a/index.html +++ b/index.html @@ -64,7 +64,7 @@ </section> <!-- Agenda --> - <section> + <section id="agenda"> <!-- nested agenda sections --> <section data-markdown> ## Agenda @@ -85,6 +85,16 @@ - Runners - Questions </section> + + <section data-markdown> + Complementary: + - [Docker](#/docker) + + Note: + - The docker item is a link to the slides + - The docker slides have a back link to the agenda + - Complementary material, not required but useful + </section> </section> <!-- Concepts --> @@ -111,8 +121,16 @@ data-charset="iso-8859-15"> </section> - <!-- Why use CI --> - <section data-markdown="content/what_git.md" + <!-- GitLab ci yml file --> + <section data-markdown="content/gitlab-ci-yml.md" + data-separator="^\n\n\n" + data-separator-vertical="^----------" + data-separator-notes="^Note:" + data-charset="iso-8859-15"> + </section> + + <!-- Runners--> + <section data-markdown="content/runners.md" data-separator="^\n\n\n" data-separator-vertical="^----------" data-separator-notes="^Note:" @@ -130,6 +148,15 @@ they have none at the moment </section> + <!-- Docker --> + <section data-markdown="content/docker.md" + data-separator="^\n\n\n" + data-separator-vertical="^----------" + data-separator-notes="^Note:" + data-charset="iso-8859-15" + id="docker"> + </section> + </div> </div>