diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b6cf10a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.aes +dockercfg diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..66b8681 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +# base on latest ruby base image +FROM ruby:2.5.0 + +# install dependencies +RUN apt-get update && apt-get install -y build-essential libpq-dev nodejs apt-utils + +# declare /app as working directory of image +WORKDIR /app + +# copy over Gemfile and Gemfile.lock to image's working directory, then run `bundle install` +COPY Gemfile Gemfile.lock ./ +RUN bundle install --jobs 20 --retry 5 + +# copy all remaining files/folders in project directory to the container +COPY . /app diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..1211fff --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +# Gemfile +source 'https://rubygems.org' + +ruby '2.5.0' + +gem 'redis' +gem 'pg' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..5cc91fa --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,18 @@ +GEM + remote: https://rubygems.org/ + specs: + pg (1.1.4) + redis (4.1.0) + +PLATFORMS + ruby + +DEPENDENCIES + pg + redis + +RUBY VERSION + ruby 2.5.0p0 + +BUNDLED WITH + 1.16.1 diff --git a/check.rb b/check.rb new file mode 100644 index 0000000..5559e1e --- /dev/null +++ b/check.rb @@ -0,0 +1,18 @@ +require "redis" +require "pg" + +def exit_if_not(expected, current) + puts "Expected: #{expected}" + puts "Current: #{current}" + exit(1) if expected != current +end + +puts "Redis" +redis = Redis.new(host: "redis") +puts "REDIS VERSION: #{redis.info["redis_version"]}" + +sleep 4 +postgres_username = "postgres" +postgres_password = "" +test = PG.connect("postgres", 5432, "", "", "postgres", postgres_username, postgres_password) +puts test.exec("SELECT version();").first["version"] diff --git a/codeship-services.yml b/codeship-services.yml new file mode 100644 index 0000000..8e0de75 --- /dev/null +++ b/codeship-services.yml @@ -0,0 +1,14 @@ +demo: + build: + image: myapp + dockerfile: Dockerfile + depends_on: + - redis + - postgres + environment: + TEST_TOKEN: Testing123 +redis: + image: healthcheck/redis:alpine +postgres: + image: healthcheck/postgres:alpine + diff --git a/codeship-steps.yml b/codeship-steps.yml new file mode 100644 index 0000000..97da132 --- /dev/null +++ b/codeship-steps.yml @@ -0,0 +1,20 @@ +- name: ruby + service: demo + command: bundle exec ruby check.rb +- type: parallel + steps: + - name: checkrb + service: demo + command: bundle exec ruby check.rb + - name: test + service: demo + command: bundle exec ruby test.rb + +- type: serial + steps: + - name: dockerhub_push + service: demo + type: push + image_name: petrasargent/get-started + registry: https://index.docker.io/v1/ + encrypted_dockercfg_path: dockercfg.encrypted diff --git a/dockercfg.encrypted b/dockercfg.encrypted new file mode 100644 index 0000000..ca0111a --- /dev/null +++ b/dockercfg.encrypted @@ -0,0 +1,2 @@ +codeship:v2 +KtdVV0Sx3sjP1vWyLDvtcIJkg+EdP5w/MpErOaojdjko7tTdyqx9u+Pg/YKU+Z+QHEFoujdjrakUeeiLZu2huo+jSDpZjFuYZAWSv/ch1o1k2tD6koQrbodo1StsY5XHfFqAWDoZvb/0YhsmF5qB+KMRi0dNmXucXaSxemUkAm1YIilH/Fp9hYpwhlerqKLTg0HyUcT88XbAnxxQgEczVZCp9jLP1ldMs0qoMId9MrpTVH6yu8qBE1d+Uh2HMVSH1DTkejZ27ECYNg== \ No newline at end of file diff --git a/helloWorkshop.java b/helloWorkshop.java index d7d912e..cad40cc 100644 --- a/helloWorkshop.java +++ b/helloWorkshop.java @@ -2,14 +2,15 @@ /* 9-12-12 */ class helloWorkshop { public static void main(String[] args) { - System.out.println("Greetings Workshop!"); - System.out.println("This is an example file"); + System.out.println("Greetings Everyone!"); + System.out.println("This is example Java file"); System.out.println("for use in workshop exercises."); System.out.println("This is on the master branch"); System.out.println("This file is written in Java."); - System.out.println("Isn't this exciting?"); + System.out.println("Wow! This is amazing! I love to code!"); + System.out.println("Isn't this exciting? Yes, it is!!"); System.out.println("Maybe?"); - System.out.println("Okay then."); - System.out.println("Goodbye Workshop!"); + System.out.println("Okay then. Talk to you later! Have a great weekend"); + System.out.println("Goodbye Workshop! Good Luck! See you soon. Hasta La Vista, baby"); } -} \ No newline at end of file +} diff --git a/test.rb b/test.rb new file mode 100644 index 0000000..f4e1da6 --- /dev/null +++ b/test.rb @@ -0,0 +1,7 @@ +if ENV['TEST_TOKEN'].nil? + puts "Our Variable Is Not Working" + exit 1 +else + puts "Our Variable Is Working" + exit 0 + end