Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
85 lines (63 loc) · 2.75 KB
/
Copy pathDockerfile
File metadata and controls
85 lines (63 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# https://hub.docker.com/r/stefansundin/rssbox
# docker pull stefansundin/rssbox
# docker run --rm -it -p 3000:3000 stefansundin/rssbox
# docker run --rm -it --entrypoint bin/cons stefansundin/rssbox
# docker network create rssbox
# docker run --rm --network=rssbox --name=redis redis redis-server --appendonly yes
# docker run --rm --network=rssbox --name=rssbox --env-file=.dockerenv -i -t -p 3000:3000 stefansundin/rssbox
# docker run --rm --network=rssbox -t redis redis-cli -h redis monitor
# Simple build:
# docker build --pull --progress plain -t stefansundin/rssbox .
# Multi-arch:
# docker buildx create --use --name multiarch --node multiarch0
# docker buildx build --pull --push --progress plain --platform linux/amd64,linux/arm64,linux/riscv64 -t stefansundin/rssbox .
# Push to public ECR:
# docker buildx imagetools create -t public.ecr.aws/stefansundin/rssbox stefansundin/rssbox
# Verify jemalloc:
# docker run --rm -it --entrypoint ruby -e MALLOC_CONF=stats_print:true stefansundin/rssbox -- -e exit
# Verify YJIT:
# docker run --rm -it --entrypoint ruby -e RUBYOPT="--yjit" stefansundin/rssbox -e "puts RUBY_DESCRIPTION"
FROM ruby:4.0 AS builder
RUN echo 'gem: --no-document' >> /usr/local/etc/gemrc
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN bundle config set --local without development:test
RUN bundle config set --local deployment true
RUN bundle install --retry=3 --jobs=4
FROM ruby:4.0-slim
LABEL org.opencontainers.image.authors="Stefan Sundin"
LABEL org.opencontainers.image.url="https://github.com/stefansundin/rssbox"
RUN \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
libjemalloc2 \
vim less procps && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN ln -s $(uname -m)-linux-gnu/libjemalloc.so.2 /usr/lib/libjemalloc.so.2
ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2
ENV MALLOC_ARENA_MAX=2
# Make it possible to execute gem binaries without "bundle exec"
ENV GEM_PATH=/app/vendor/bundle/ruby/4.0.0
ENV PATH=$GEM_PATH/bin:$PATH
RUN echo 'PATH=$GEM_PATH/bin:$PATH' > /etc/profile.d/path.sh
ENV APP_ENV=production
WORKDIR /app
COPY --from=builder /usr/local/etc/gemrc /usr/local/etc/gemrc
COPY --from=builder /usr/local/bundle/config /usr/local/bundle/config
COPY --from=builder /app /app
RUN bundle check
COPY . .
RUN find -not -path './vendor/*'
# Disable irb history to prevent .irb_history permission error from showing
RUN echo "IRB.conf[:SAVE_HISTORY] = nil" >> .irbrc
# Touch config/application.rb to indicate when the docker image was built
RUN touch config/application.rb
# Run the container as an unprivileged user
RUN mkdir -p tmp /nonexistent
RUN chown nobody:nogroup tmp /nonexistent
USER nobody:nogroup
EXPOSE 3000
ENV PORT=3000
ENTRYPOINT ["bundle", "exec", "puma", "-C", "config/puma.rb"]