-
Notifications
You must be signed in to change notification settings - Fork 53
/
Dockerfile
62 lines (45 loc) · 2.23 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
# Pinned to the latest ruby 3.2 version of the Passenger base Docker image
FROM phusion/passenger-ruby32:2.5.0
RUN mv /etc/apt/sources.list.d /etc/apt/sources.list.d.bak
RUN apt update && apt install -y ca-certificates
RUN mv /etc/apt/sources.list.d.bak /etc/apt/sources.list.d
RUN apt-get update \
&& apt-get upgrade -y -o Dpkg::Options::="--force-confold" \
&& apt-get install -y nodejs tzdata \
&& rm -rf /var/lib/apt/lists/*
ENV RAILS_ENV production
ENV RAILS_SERVE_STATIC_FILES 1
RUN mkdir /home/app/cypress
WORKDIR /home/app/cypress
RUN bash -lc 'rvm install ruby-3.2.2'
RUN bash -lc 'rvm --default use ruby-3.2.2'
ADD Gemfile /home/app/cypress/Gemfile
ADD Gemfile.lock /home/app/cypress/Gemfile.lock
RUN chown -R app:app .
RUN su app -c 'bundle install'
ADD . /home/app/cypress
# If the tmp directory doesn't exist then the app will not be able to run.
# By creating it here it will get chowned correctly by the next declaration.
RUN mkdir -p tmp public/data
# DISABLE_DB disables an initializer that requires the DB to run, so we can precompile in the Docker build phase
# SECRET_KEY_BASE sets a dummy secret key, so that the precompiler (which doesn't need the secret key for anything) can run
RUN RAILS_ENV=production DISABLE_DB=true SECRET_KEY_BASE=precompile_only bundle exec rake assets:precompile
# This line is a duplicate however it is done to significantly speed up testing. With this line twice
# we are able to do the bundle install earlier on which means it is cached more often.
RUN chown -R app:app .
RUN chmod -R 0755 .
RUN mkdir /etc/service/unicorn
ADD docker_unicorn_start.sh /etc/service/unicorn/run
RUN chmod 755 /etc/service/unicorn/run
RUN mkdir /etc/service/cypress_delayed_job_1
ADD docker_delayed_job.sh /etc/service/cypress_delayed_job_1/run
RUN chmod 755 /etc/service/cypress_delayed_job_1/run
# Setup other workers based on first worker. This makes it where tweaking the number of workers
# just requires changing this WORKER_COUNT. Unfortunately does not allow tweaking after build is completed.
ARG WORKER_COUNT=4
RUN if [ $WORKER_COUNT -gt 1 ]; then \
for i in $(seq 2 1 $WORKER_COUNT); do \
cp -R /etc/service/cypress_delayed_job_1 /etc/service/cypress_delayed_job_$i; \
done; \
fi
EXPOSE 3000