Skip to content

Instantly share code, notes, and snippets.

@lguardiola
Forked from inkel/Dockerfile
Last active August 29, 2015 14:25
Show Gist options
  • Save lguardiola/466069e1b92b13eed4be to your computer and use it in GitHub Desktop.
Save lguardiola/466069e1b92b13eed4be to your computer and use it in GitHub Desktop.
# checker.rb
# https://blog.codeship.com/build-minimal-docker-container-ruby-apps/
require 'rubygems'
require 'curb'
gem_name = ARGV[0]
raise ArgumentError.new("gem name missing") if gem_name.nil?
if Curl.get("https://rubygems.org/gems/#{gem_name}").status == '200 OK'
$stdout.puts 'Name not available.'
else
$stdout.puts 'Name available.'
end
FROM alpine:3.2
MAINTAINER Leandro López <[email protected]>
# Install base packages
RUN apk update && apk upgrade
# Install ruby and ruby-bundler
RUN apk add curl-dev ruby-dev build-base ruby
# Clean APK cache
RUN rm -rf /var/cache/apk/*
RUN mkdir /usr/app
WORKDIR /usr/app
COPY . /usr/app
RUN gem install --no-ri --no-rdoc -E curb
ENTRYPOINT ["ruby", "checker.rb"]
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ruby latest 7bacacd41c6d 3 minutes ago 183.2 MB
[
{
"Id": "7bacacd41c6d5cc37b9b0d71796b00cc97673df6cd1e2dc04ab8c98762db5e5a",
"Parent": "467e02a8493dcadd0061ec26e2f813dbf34b23f77b070ebfc979e01a023b4a5e",
"Comment": "",
"Created": "2015-07-20T22:16:41.836628382Z",
"Container": "c9dea761c45d22c333c67caa6bb98442dffbf11dbea476e6adc12d9a5ff2582d",
"ContainerConfig": {
"Hostname": "bfbdc5abbb9f",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"PortSpecs": null,
"ExposedPorts": null,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ENTRYPOINT \u0026{[\"ruby\" \"checker.rb\"]}"
],
"Image": "467e02a8493dcadd0061ec26e2f813dbf34b23f77b070ebfc979e01a023b4a5e",
"Volumes": null,
"VolumeDriver": "",
"WorkingDir": "/usr/app",
"Entrypoint": [
"ruby",
"checker.rb"
],
"NetworkDisabled": false,
"MacAddress": "",
"OnBuild": [],
"Labels": {}
},
"DockerVersion": "1.7.1",
"Author": "Leandro López \[email protected]\u003e",
"Config": {
"Hostname": "bfbdc5abbb9f",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"PortSpecs": null,
"ExposedPorts": null,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": null,
"Image": "467e02a8493dcadd0061ec26e2f813dbf34b23f77b070ebfc979e01a023b4a5e",
"Volumes": null,
"VolumeDriver": "",
"WorkingDir": "/usr/app",
"Entrypoint": [
"ruby",
"checker.rb"
],
"NetworkDisabled": false,
"MacAddress": "",
"OnBuild": [],
"Labels": {}
},
"Architecture": "amd64",
"Os": "linux",
"Size": 0,
"VirtualSize": 183156199
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment