Skip to content

Commit

Permalink
add ruby demo
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosdotps committed Oct 20, 2024
1 parent 1ec00c9 commit 6975b7c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ruby:bullseye

COPY ./app.rb /tmp

CMD ["ruby", "/tmp/app.rb"]

3 changes: 3 additions & 0 deletions ruby/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: build
build:
docker build -t parca-demo:ruby .
48 changes: 48 additions & 0 deletions ruby/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'prime'
require 'fileutils'

STDOUT.sync = true

def a(n)
b(n)
end

def b(n)
## Make some calculations
i = 100_000
while i > 0 do
Prime.prime?(i)
i -= 1
end
c(n)
end

def c(n)
## Create a new file
File.open("test.txt", "w") do |f|
f.write("Hello, world!")
end
## Pass new file to d
d("test.txt")
end

def d(file)
## Read file
File.open(file, "r") do |f|
## Print file contents and time
puts f.read + " :: " + Time.now.to_s
end
f(file)
end

def f(file)
## Delete file
File.delete(file)
end

## Infinte loop
while true
sleep(1)
a(1)
end

25 changes: 25 additions & 0 deletions ruby/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: demo-ruby
name: ruby
namespace: parca
spec:
replicas: 3
selector:
matchLabels:
app.kubernetes.io/name: demo-ruby
template:
metadata:
labels:
app.kubernetes.io/name: demo-ruby
spec:
containers:
- image: parca-demo:ruby
name: python
resources:
limits:
cpu: "100m"
memory: "256Mi"

0 comments on commit 6975b7c

Please sign in to comment.