Closed so0k closed 7 years ago
at the Dockerfile
stage, should add Gemfile instructions
running locally, echo Twitter vars to .secret
load .secret
to env for testing locally:
export $(cat .secret | xargs)
Changed my Dockerfile as follows (notice --standalone
flag for bundler and re-order layers):
FROM alpine:3.4
RUN apk --no-cache add bash build-base ca-certificates \
ruby ruby-dev ruby-bundler ruby-io-console
RUN adduser -D bundle
USER bundle
WORKDIR /home/bundle
COPY Gemfile .
RUN bundle install --standalone
COPY . /home/bundle
Added bundle/bundler/setup
to tweet.rb
#!/usr/bin/env ruby
require_relative 'bundle/bundler/setup'
require 'twitter'
client = Twitter::REST::Client.new(
consumer_key: ENV["TWITTER_CONSUMER_KEY"],
consumer_secret: ENV["TWITTER_CONSUMER_SECRET"],
access_token: ENV["TWITTER_ACCESS_TOKEN"],
access_token_secret: ENV["TWITTER_ACCESS_TOKEN_SECRET"])
message = ARGV.join(" ")
tweet = client.update(message)
puts <<-EOM
Message: #{message}
URL: #{tweet.url}
EOM
build container image:
docker build -t vincentdesmet/twitter_example:0.0.1 .
run test container:
docker run -it --rm --env-file=.secret vincentdesmet/twitter_example:0.0.1 /bin/sh
this drops you in a ash
shell (Alpine), from which you may run ./tweet.rb with arguments or wrapper with env vars
Todo:
must have twitter_example:tweet
@cog permission grant twitter_example:tweet cog-admin
in the section for ease of following alongListing 26. Final Bundle Configuration
is missing the permissions key at the end of the config.yaml
and line 29 description
of the --as
option should be updated2nd paragraph of https://cog-book.operable.io/#_authorization_rules has a broken link, the link should be: http://docs.operable.io/docs/command-execution-rules
@so0k Apologies for the slow review. We'll have some feedback for you soon.
just in case reader is really unfamiliar with Ruby?