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 #
## 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
 
- 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
## 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
Loading
Loading
@@ -64,7 +64,7 @@
</section>
 
<!-- Agenda -->
<section>
<section id="agenda">
<!-- nested agenda sections -->
<section data-markdown>
## Agenda
Loading
Loading
@@ -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 -->
Loading
Loading
@@ -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:"
Loading
Loading
@@ -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>
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