This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
89 lines (70 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
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
FROM ruby:3.0.2-alpine3.13
MAINTAINER Cross Justice Delivery Team
# 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 some required directories
RUN mkdir -p /usr/src/app && \
mkdir -p /usr/src/app/log && \
mkdir -p /usr/src/app/tmp && \
mkdir -p /usr/src/app/tmp/pids
WORKDIR /usr/src/app
COPY Gemfile* .ruby-version ./
RUN gem install bundler && \
bundle config set frozen 'true' && \
bundle config without test:development && \
bundle install --jobs 2 --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 RAILS_ENV production
RUN rails assets:precompile --trace
# 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 PORT 3000
EXPOSE $PORT
ENTRYPOINT ["./run.sh"]