-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile.production
More file actions
79 lines (58 loc) · 1.64 KB
/
Dockerfile.production
File metadata and controls
79 lines (58 loc) · 1.64 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
FROM docker.io/ruby:4.0.0-alpine3.23 AS base
RUN apk update \
&& apk upgrade \
&& apk add \
build-base shared-mime-info mariadb-dev sqlite-dev yaml-dev tzdata imagemagick \
nodejs npm \
&& rm -rfv /var/cache/apk/*
# These are equivalent to always setting --deployment, --path, and --without when relevant.
ENV BUNDLE_DEPLOYMENT="1"
# Don't install to vendor/bundle.
ENV BUNDLE_PATH="/usr/local/bundle"
ENV BUNDLE_WITHOUT="development"
ENV RAILS_ENV="production"
WORKDIR /tap
FROM base AS builder
COPY Gemfile Gemfile.lock ./
RUN --mount=type=cache,target=vendor/cache bundle install && bundle cache
RUN bundle exec bootsnap precompile --gemfile
COPY package.json package-lock.json* ./
RUN --mount=type=cache,target=/root/.npm npm ci
COPY --parents \
./app/ \
./bin/ \
./config/ \
./db/ \
./lib/ \
./log/.keep \
./public/ \
./config.ru \
./Rakefile \
./
RUN npm run build:js
RUN bundle exec bootsnap precompile app/ lib/
RUN <<"EOF"
export TAP_SECRET_KEY_BASE=1
./bin/rails javascript:build
./bin/rails assets:precompile
EOF
FROM base AS runner
COPY --from=builder "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=builder /tap /tap
EXPOSE 80
COPY --chmod=755 <<"EOF" /entrypoint.sh
#!/bin/sh
set -eu
# Enable jemalloc for reduced memory usage and latency.
LD_PRELOAD=/usr/lib/libjemalloc.so.2
until ./bin/rails db:version 2>/dev/null; do
echo "Waiting for database to start..."
sleep .1
done
# Create or migrate the database
./bin/rails db:prepare
./bin/delayed_job start
exec "${@}"
EOF
ENTRYPOINT ["/entrypoint.sh"]
CMD ["./bin/rails", "server", "--binding=0.0.0.0", "--port=80"]