-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
99 lines (82 loc) · 2.57 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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
FROM ruby:3.3.1-alpine3.18 AS builder
LABEL maintainer="Max Fierke <[email protected]>" \
description="Build image for resumis"
ENV APP_HOME=/resumis \
NODE_ENV=production \
RAILS_ENV=production \
RESUMIS_USER=resumis
# Build-time deps
RUN apk add --update --no-cache \
build-base \
linux-headers \
nodejs \
yarn \
tzdata \
gcompat \
libxml2-dev \
libxslt-dev \
libgcc libstdc++ \
git \
postgresql-dev
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME
ADD ./Gemfile* $APP_HOME/
RUN bundle config --global frozen 1 \
&& bundle config build.nokogiri --use-system-libraries \
&& bundle config set without development test \
&& bundle install --retry 3 \
# Remove unneeded files (cached *.gem, *.o, *.c)
&& rm -rf /usr/local/bundle/cache/*.gem \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete
ADD ./package.json ./yarn.lock $APP_HOME/
RUN yarn install
ADD . $APP_HOME
# Precompile assets & bootsnap cache
RUN SECRET_KEY_BASE=IGNORE_ME_I_AM_A_BAD_KEY_BASE bundle exec rake assets:precompile && \
rm -rf node_modules tmp/cache && \
bundle exec bootsnap precompile --gemfile app/ lib/
# Runtime image
FROM ruby:3.3.1-alpine3.18
LABEL maintainer="Max Fierke <[email protected]>" \
description="An API for your personal site & resume"
ENV APP_HOME=/resumis \
NODE_ENV=production \
RAILS_ENV=production \
RAILS_SERVE_STATIC_FILES=true \
RAILS_LOG_TO_STDOUT=true \
RESUMIS_DEPLOY_ROOT=/resumis \
RESUMIS_TENANCY_MODE=single \
RESUMIS_USER=resumis \
RUBY_YJIT_ENABLE=1 \
PORT=5000 \
WKHTMLTOPDF_PATH=/usr/bin/wkhtmltopdf
RUN mkdir -p $APP_HOME/shared/pids
RUN addgroup -g 1000 -S $RESUMIS_USER && \
adduser -u 1000 -S $RESUMIS_USER -G $RESUMIS_USER -D
# Runtime deps
RUN apk add --update --no-cache \
postgresql-client \
file \
jemalloc \
imagemagick vips \
tzdata \
gcompat \
# PDF stuff
libintl \
libcrypto3 libssl3 \
ttf-dejavu ttf-droid ttf-freefont ttf-liberation \
weasyprint
ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2 \
MALLOC_CONF=dirty_decay_ms:1000,narenas:2,background_thread:true
WORKDIR $APP_HOME
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder $APP_HOME $APP_HOME
RUN chown -R $RESUMIS_USER:$RESUMIS_USER $APP_HOME
# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout log/puma.log && ln -sf /dev/stderr log/production.log
USER $RESUMIS_USER
EXPOSE 5000
RUN date -u > IMAGE_BUILD_TIME
ENTRYPOINT [ "./entrypoint.sh" ]
CMD [ "bundle", "exec", "puma", "-C", "config/puma.rb" ]