-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
115 lines (91 loc) · 2.64 KB
/
Dockerfile
File metadata and controls
115 lines (91 loc) · 2.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# syntax = docker/dockerfile:1.21@sha256:27f9262d43452075f3c410287a2c43f5ef1bf7ec2bb06e8c9eeb1b8d453087bc
FROM docker.io/ruby:3.4.2-slim@sha256:98e208daf93d40485edf2f5e1a1527202ae0824cdc1619b6659674a84aa197ba AS build
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV BRAND=${BRAND}
ENV MALLOC_ARENA_MAX=2
ENV RAILS_ENV=production
RUN mkdir --parents /app/
WORKDIR /app/
# Install dependencies for installing gems
RUN <<EOF
apt-get --yes --quiet update
apt-get --yes --quiet install \
build-essential \
git \
libcurl4 \
libffi-dev \
libidn11-dev \
libpq-dev \
libsodium23 \
libyaml-dev \
pax-utils \
shared-mime-info \
tzdata
EOF
COPY Gemfile* /app/
RUN <<EOF
gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
bundle config set --local without 'development test integration'
bundle install --jobs 4 --retry 3
EOF
# Scan gem files for linked native libaries, lookup the packages they
# are shipped with, and colled it list into a file so that only required
# packages can be installed in the runtime image below.
RUN <<EOF
scanelf --recursive --needed --nobanner --format '%n#p' /usr/local/bundle/ \
| tr ',' '\n' \
| sort -u \
| grep -v libruby.so* \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| tee /usr/local/bundle/packages
EOF
# Copy rest of the application (see .dockerignore too)
COPY . /app/
# Cleanup application directory
RUN <<EOF
rm -r ./docker
EOF
#
# Runtime image
#
FROM docker.io/ruby:3.4.2-slim@sha256:98e208daf93d40485edf2f5e1a1527202ae0824cdc1619b6659674a84aa197ba
ARG TARGETARCH
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV BRAND=${BRAND}
ENV MALLOC_ARENA_MAX=2
ENV RAILS_ENV=production
ENV RAILS_LOG_TO_STDOUT=1
RUN mkdir --parents /app/
WORKDIR /app/
# Add system user for running the app
RUN useradd --create-home --shell /bin/bash xikolo
# Install extra dependencies for runtime environment
RUN <<EOF
apt-get --yes --quiet update
apt-get --yes --quiet --no-install-recommends install \
curl \
git \
libcurl4 \
libsodium23 \
libyaml-dev \
nginx \
shared-mime-info \
tzdata \
xz-utils
EOF
COPY docker/rootfs/ /
COPY docker/bin/ /docker/bin
RUN /docker/bin/install-s6-overlay
# Copy installed gems and config from `build` stage above
COPY --from=build /usr/local/bundle /usr/local/bundle
# Install required runtime packages for native dependencies
RUN <<EOF
xargs apt-get install --yes < /usr/local/bundle/packages
EOF
# Copy application files from build stage
COPY --from=build /app/ /app/
EXPOSE 80/tcp
CMD [ "server" ]
ENTRYPOINT [ "/init", "with-contenv", "/app/bin/entrypoint" ]