-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathDockerfile
60 lines (46 loc) · 1.78 KB
/
Dockerfile
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
FROM ruby:alpine3.16 as rdbbuilder
WORKDIR /app
ENV BUNDLE_GEMFILE=Gemfile.build
COPY Gemfile.build* init.rb /app/
COPY data /app/data/
RUN echo "** installing deps **" && \
apk --no-cache add redis && \
echo "** installing ruby gems **" && \
bundle install && \
echo "** starting redis-server **" && \
redis-server --daemonize yes && \
echo "** running build script **" && \
bundle exec ruby init.rb
FROM ruby:alpine3.16
WORKDIR /app
# Being explicit here, not needed
ENV BUNDLE_GEMFILE=Gemfile
# Just copy enough to install dependencies and maintain cache
COPY Gemfile Gemfile.lock /app/
RUN echo "** installing deps **" && \
apk --no-cache add dumb-init redis libstdc++ && \
echo "** installing eventmachine-build-deps **" && \
apk --no-cache add --virtual .eventmachine-builddeps g++ make && \
echo "** install healthcheck deps **" && \
apk --no-cache add curl && \
echo "** updating bundler **" && \
gem update bundler && \
echo "** installing ruby gems **" && \
bundle config set --local without 'testing' && \
bundle install && \
echo "** removing eventmachine-build deps **" && \
apk del .eventmachine-builddeps
COPY --from=rdbbuilder /app/dump.rdb /app/
# This is not clean because we can't run a COPY . anymore
# Since that would copy the data directory
# We can't add data to dockerignore, since it is used in first stage
COPY README.md app.rb metrics.rb config.ru entrypoint.sh /app/
COPY public /app/public/
COPY views /app/views/
EXPOSE 3000
ENTRYPOINT ["/app/entrypoint.sh"]
# Create a group and user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Tell docker that all future commands should run as the appuser user
USER appuser
HEALTHCHECK --start-period=200s CMD curl -I http://localhost:3000 || exit 1