-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
64 lines (50 loc) · 1.63 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
FROM ruby:3.0.4-alpine3.15
MAINTAINER crime apps team
# fail early and print all commands
RUN set -ex
# build dependencies:
# - virtual: create virtual package for later deletion
# - build-base for alpine fundamentals
# - postgresql-dev for pg/activerecord gems
# - postgresql-client for pg_dump, as we need to use sql schema_format
# - tzdata for timezone data
# - git for installing gems referred to use a git:// uri
#
RUN apk --no-cache add --virtual build-dependencies \
build-base \
postgresql-dev \
postgresql-client \
tzdata \
git
# 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/pids
WORKDIR /usr/src/app
######################
# DEPENDENCIES START #
######################
COPY Gemfile* ./
RUN gem install bundler -N
RUN bundle config set --local deployment 'true' without 'development:test' && bundle install --jobs 4
####################
# DEPENDENCIES END #
####################
# expect and set ping environment variables
ARG COMMIT_ID
ENV COMMIT_ID=${COMMIT_ID}
ARG BUILD_DATE
ENV BUILD_DATE=${BUILD_DATE}
ARG BUILD_TAG
ENV BUILD_TAG=${BUILD_TAG}
ARG APP_BRANCH
ENV APP_BRANCH=${APP_BRANCH}
ENV RAILS_SERVE_STATIC_FILES true
ENV RAILS_LOG_TO_STDOUT true
EXPOSE 3000
COPY . .
# non-root/appuser should own only what they need to
RUN chown -R appuser:appgroup app config log tmp db coverage spec
USER 1000
CMD "./docker/run"