-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
90 lines (71 loc) · 2.48 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
80
81
82
83
84
85
86
87
88
89
90
FROM ruby:3.2.2-alpine
# build dependencies:
# - virtual: create virtual package for later deletion
# - build-base for alpine fundamentals
# - libxml2-dev/libxslt-dev for nokogiri, at least
# - postgresql-dev for pg/activerecord gems
# - git for installing gems referred to use a git:// uri
#
RUN apk --no-cache add --virtual build-deps \
build-base \
libxml2-dev \
libxslt-dev \
postgresql-dev \
git \
bash \
curl \
&& apk --no-cache add \
postgresql-client \
shared-mime-info \
linux-headers \
xz-libs \
tzdata \
nodejs \
yarn
# ensure everything is executable
RUN chmod +x /usr/local/bin/*
# add non-root user and group with alpine first available uid, 1000
RUN addgroup -g 1000 -S appgroup && \
adduser -u 1000 -S appuser -G appgroup
# create app directory in conventional, existing dir /usr/src
RUN mkdir -p /usr/src/app && mkdir -p /usr/src/app/tmp
WORKDIR /usr/src/app
COPY Gemfile* .ruby-version ./
RUN gem install bundler -v 2.4.19
RUN bundle config deployment true && \
bundle config without development test && \
bundle install --jobs 4 --retry 3
COPY . .
# The following are ENV variables that need to be present by the time
# the assets pipeline run, but doesn't matter their value.
#
ENV EXTERNAL_URL replace_this_at_build_time
ENV SECRET_KEY_BASE replace_this_at_build_time
ENV GOVUK_NOTIFY_API_KEY replace_this_at_build_time
ENV RAILS_ENV production
RUN bundle exec rake assets:precompile
# Copy fonts and images (without digest) along with the digested ones,
# as there are some hardcoded references in the `govuk-frontend` files
# that will not be able to use the rails digest mechanism.
RUN cp -r node_modules/govuk-frontend/dist/govuk/assets/. public/assets/
# tidy up installation
RUN apk del build-deps && rm -rf /tmp/*
# non-root/appuser should own only what they need to
RUN chown -R appuser:appgroup log tmp db
# Download RDS certificates bundle -- needed for SSL verification
# We set the path to the bundle in the ENV, and use it in `/config/database.yml`
#
ENV RDS_COMBINED_CA_BUNDLE /usr/src/app/config/rds-combined-ca-bundle.pem
ADD https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem $RDS_COMBINED_CA_BUNDLE
RUN chmod +r $RDS_COMBINED_CA_BUNDLE
ARG APP_BUILD_DATE
ENV APP_BUILD_DATE ${APP_BUILD_DATE}
ARG APP_BUILD_TAG
ENV APP_BUILD_TAG ${APP_BUILD_TAG}
ARG APP_GIT_COMMIT
ENV APP_GIT_COMMIT ${APP_GIT_COMMIT}
ENV APPUID 1000
USER $APPUID
ENV PUMA_PORT 3000
EXPOSE $PUMA_PORT
ENTRYPOINT ["./run.sh"]