-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile
79 lines (60 loc) · 1.79 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
# syntax=docker/dockerfile:1.4
FROM ruby:3.2.2-slim-bookworm AS ruby
WORKDIR /app
SHELL ["/bin/bash", "-c"]
CMD ["/bin/bash"]
RUN \
--mount=type=cache,id=activerecord_views-apt-cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=activerecord_views-apt-lib,sharing=locked,target=/var/lib/apt \
<<SH
set -euo pipefail
dpkg-reconfigure debconf --frontend=noninteractive
rm /etc/apt/apt.conf.d/docker-clean
cat > /etc/apt/apt.conf.d/docker-local <<EOF
APT::Install-Suggests "0";
APT::Install-Recommends "0";
Binary::apt::APT::Keep-Downloaded-Packages "true";
EOF
set -x
apt-get update --yes
apt-get install -y \
build-essential gnupg2 postgresql-common libpq-dev
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh <<<$(echo)
apt-get install -y postgresql-client-16
SH
COPY .tool-versions ./
RUN <<SH
set -euo pipefail
ruby --version
(
echo "ruby ${RUBY_VERSION?}"
) | diff - .tool-versions
SH
COPY Gemfile* *.gemspec Appraisals .
COPY lib/active_record_views/version.rb lib/active_record_views/
COPY gemfiles gemfiles
RUN \
--mount=type=cache,id=activerecord_views-bundle-cache,target=/var/cache/bundle \
<<SH
set -euo pipefail
BUNDLE_CACHE_PATH="/var/cache/bundle/debian-$(cat /etc/debian_version)-ruby-$RUBY_VERSION"
(
export GEM_HOME="$BUNDLE_CACHE_PATH"
set -x
gem install bundler
bundle install
bundle exec appraisal install
)
echo "Copying bundle cache to target..."
tar c -C "$BUNDLE_CACHE_PATH" --anchored --no-wildcards-match-slash --exclude=./cache . | tar x -C "$GEM_HOME"
SH
COPY . ./
RUN <<SH
set -euo pipefail
for DIR in /tmp /app/tmp /app/spec/internal/db /app/spec/internal/app/models_temp /app/spec/internal/log; do
mkdir -p "$DIR"
chmod 1777 "$DIR"
done
useradd -m user
SH
USER user