Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating script to work in 2019 #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
FROM alpine:3.2
FROM alpine:latest
MAINTAINER CenturyLink Labs <[email protected]>

RUN apk --update add ruby-dev ca-certificates && \
gem install --no-rdoc --no-ri docker-api && \
apk del ruby-dev ca-certificates && \
apk add ruby ruby-json && \
RUN apk --update add \
gcc \
libc-dev \
make \
ruby \
ruby-dev \
ruby-irb \
ruby-json && \
gem install --no-rdoc --no-ri bundler -v 1.16.1 && \
rm /var/cache/apk/*

WORKDIR /usr/src/app
ADD Gemfile /usr/src/app/
ADD Gemfile.lock /usr/src/app/
RUN bundle
ADD dockerfile-from-image.rb /usr/src/app/dockerfile-from-image.rb

ENTRYPOINT ["/usr/src/app/dockerfile-from-image.rb"]
ENTRYPOINT ["/usr/bin/bundle", "exec", "ruby", "/usr/src/app/dockerfile-from-image.rb"]
CMD ["--help"]
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

gem 'docker'
gem 'docker-api'
21 changes: 21 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
GEM
remote: https://rubygems.org/
specs:
backticks (1.0.2)
docker (0.4.0)
backticks (~> 1.0.0)
docker-api (1.34.2)
excon (>= 0.47.0)
multi_json
excon (0.62.0)
multi_json (1.13.1)

PLATFORMS
ruby

DEPENDENCIES
docker
docker-api

BUNDLED WITH
1.16.1
4 changes: 2 additions & 2 deletions dockerfile-from-image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
# Collect all image tags into a hash keyed by layer ID.
# Used to look-up potential FROM targets.
tags = Docker::Image.all.each_with_object({}) do |image, hsh|
tag = image.info['RepoTags'].first
hsh[image.id] = tag unless tag == NONE_TAG
tag = image.info['RepoTags']&.first
hsh[image.id] = tag if tag && tag != NONE_TAG
end

loop do
Expand Down