Skip to content
Snippets Groups Projects
Commit 548e4150 authored by Jose Torres's avatar Jose Torres
Browse files

Adds sample app and Runners sections

parent c0c17b35
No related branches found
No related tags found
1 merge request!3Adds sample app and Runners sections
Pipeline #
This commit is part of merge request !3. Comments created here will be created in the context of that merge request.
## 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)
## 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
``` ```
## Runners ## Runners
   
- Choose a directory on you machine easy to access - A runner is an isolated (virtual) machine that picks up builds through the
- Create a workspace or development directory coordinator API of GitLab CI.
- This is where we'll be working and adding content
   
---------- - You can create as many Runners as you need on different machines
   
``` - The Runners screen
mkdir ~/development
cd ~/development
   
-or- - Specific vs Shared Runners
   
mkdir ~/workspace - Installation vs registration
cd ~/workspace
``` - Tagged Runners
## Sample App ## Sample App
   
---------- ----------
   
## Docker ### Main Objectives
- Build a web application on Ruby on Rails
Download and modify a Docker image: - Create an integration workflow
- Automate deployments
   
``` ---
docker images
docker run -t -i ruby:2.3 /bin/bash
   
$ apt-get update ### Complementary
$ apt-get install nodejs -y - Project landing page
$ gem install bundler --no-ri --no-rdoc - Docker environment for build and development
# A Dockerfile is a great option for the following line or
# maybe integrate with our current CI script?
$ bundle install
$ exit
   
# Log back in? Note:
docker ps -a # and get container sha - Add some interesting context such as "we're getting hired to do ABC"
docker start -i <container-sha>
```
   
---------- ----------
## 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 ### App and CI Tour
# docker login registry.gitlab.com
docker login <url>:<port>
   
# Push image to registry - Review files and repository
# docker push registry.gitlab.com/gitlab-org/ci-training-sample - View CI badge
docker push <registry-url>/<group-name>/<project-name>:<tag> - Talk about the pipeline and builds
``` - Talk about environments
- Cycle Analytics
- Activating builds
Loading
@@ -64,7 +64,7 @@
Loading
@@ -64,7 +64,7 @@
</section> </section>
   
<!-- Agenda --> <!-- Agenda -->
<section> <section id="agenda">
<!-- nested agenda sections --> <!-- nested agenda sections -->
<section data-markdown> <section data-markdown>
## Agenda ## Agenda
Loading
@@ -85,6 +85,16 @@
Loading
@@ -85,6 +85,16 @@
- Runners - Runners
- Questions - Questions
</section> </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> </section>
   
<!-- Concepts --> <!-- Concepts -->
Loading
@@ -111,8 +121,16 @@
Loading
@@ -111,8 +121,16 @@
data-charset="iso-8859-15"> data-charset="iso-8859-15">
</section> </section>
   
<!-- Why use CI --> <!-- GitLab ci yml file -->
<section data-markdown="content/what_git.md" <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="^\n\n\n"
data-separator-vertical="^----------" data-separator-vertical="^----------"
data-separator-notes="^Note:" data-separator-notes="^Note:"
Loading
@@ -130,6 +148,15 @@
Loading
@@ -130,6 +148,15 @@
they have none at the moment they have none at the moment
</section> </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>
   
</div> </div>
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment