Skip to content

Commit

Permalink
Optimize docker image as suggested in #97
Browse files Browse the repository at this point in the history
  • Loading branch information
nning committed Nov 16, 2022
1 parent 8d6eabd commit d8b5bff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ os:
- osx

rvm:
- ruby-head
- 2.7
- 2.5
- 2.1
- 2.7 # Current stable
- 2.6 # Alpine 3.11
- 2.5 # Debian stable (buster), Ubuntu
- 2.1 # Minimum supported version (Debian oldoldstable (jessie))

matrix:
fast_finish: true
Expand Down
26 changes: 12 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@
# docker build -t transmission-rss --build-arg UID=1337 --build-arg GID=1337 .
# docker run -it -v $(pwd)/transmission-rss.conf:/etc/transmission-rss.conf transmission-rss

FROM ruby:alpine
MAINTAINER henning mueller <[email protected]>
FROM alpine:3 as builder
RUN apk add gcc libc-dev make ruby-dev
COPY . /tmp
WORKDIR /tmp
RUN \
gem build transmission-rss.gemspec && \
gem install -N --build-root /build transmission-rss-*.gem

FROM alpine:3
MAINTAINER henning mueller <[email protected]>
ARG UID=1000
ARG GID=1000

RUN \
addgroup -g $GID ruby && \
adduser -u $UID -G ruby -D ruby && \
apk --no-cache --update add build-base libffi-dev

WORKDIR home/ruby
COPY . transmission-rss
RUN chown -R ruby:ruby transmission-rss

apk add --no-cache ruby ruby-etc ruby-json
USER ruby

WORKDIR transmission-rss
RUN bundle

CMD bundle exec ./bin/transmission-rss
COPY --from=builder /build /
CMD ["transmission-rss"]
3 changes: 2 additions & 1 deletion bin/transmission-rss
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ unless config.privileges.empty?
':' +
config.privileges.group
else
log.debug('no privilege dropping')
user = Etc.getpwuid(Process.euid).name
log.debug('no privilege dropping, running as user ' + user)
end

# Warn if no feeds are given.
Expand Down

0 comments on commit d8b5bff

Please sign in to comment.