forked from pupilfirst/pupilfirst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.evaluation
75 lines (57 loc) · 2.52 KB
/
Dockerfile.evaluation
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
FROM ruby:3.2.2-bookworm
# We'll need the exact version of PostgreSQL client, matching our server version, so let's get it from official repos.
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bookworm-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
# Now install the exact version of the client we need, along with a few other packages.
RUN apt-get update && apt-get install -y \
postgresql-client-12 \
ca-certificates \
cron \
curl \
gnupg \
libvips
# We need NodeJS & Yarn for precompiling assets.
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN echo 'Package: nodejs\nPin: origin deb.nodesource.com\nPin-Priority: 1001' > /etc/apt/preferences.d/nodesource
RUN apt-get update && apt-get install nodejs -y
RUN corepack enable
# Create a writable home directory for www-data
RUN mkdir /var/www
RUN chown -R www-data:www-data /var/www
# Set up Tini.
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
# Use the www-data user to run the application
USER www-data
WORKDIR /app
# Install gems.
COPY --chown=www-data:www-data Gemfile .
COPY --chown=www-data:www-data Gemfile.lock .
RUN gem install bundler -v '2.5.7'
RUN bundle install -j4
# Install JS dependencies using Yarn.
COPY --chown=www-data:www-data package.json .
COPY --chown=www-data:www-data yarn.lock .
COPY --chown=www-data:www-data .yarnrc.docker.yml .yarnrc.yml
COPY --chown=www-data:www-data .yarn/releases .yarn/releases
# Ignore checksum until issue with react-csv-reader is resolved.
ENV YARN_CHECKSUM_BEHAVIOR=ignore
# Install NodeJS dependencies.
RUN yarn install
# Copy over remaining files and set up for precompilation.
COPY --chown=www-data:www-data . /app
COPY --chown=www-data:www-data example.env .env
COPY --chown=www-data:www-data config/database.evaluation.yml config/database.yml
# Export the locales.json file.
RUN bundle exec i18n export
# Compile ReScript files to JS.
RUN yarn run re:build
# Run Vite's build step now so that app boots up quickly.
RUN bundle exec bin/vite build
RUN mkdir -p tmp/pids
# Use Tini.
ENTRYPOINT ["/tini", "--"]
# Run under tini to ensure proper signal handling.
CMD bin/evaluate