-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
63 lines (42 loc) · 1.43 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
ARG ALPINE_VERSION=3.19
ARG RUBY_VERSION=3.3.4
ARG DOCKER_IMAGE_DIGEST=sha256:37f4c0f791aa3c791dc2bcf052201ffd6a644fcc545aaf5ceac8231c702c7e9d
FROM ruby:${RUBY_VERSION}-alpine${ALPINE_VERSION}@${DOCKER_IMAGE_DIGEST} AS base
FROM base AS build
WORKDIR /app
RUN apk update
RUN apk upgrade --available
RUN apk add libc6-compat openssl-dev build-base libpq-dev
# Adding git so that we can bundle install gems from github
RUN apk add git
RUN adduser -D ruby
USER ruby
COPY --chown=ruby:ruby .ruby-version ./
COPY --chown=ruby:ruby Gemfile* ./
ARG BUNDLE_WITHOUT=development:test
RUN [ -z "$BUNDLE_WITHOUT" ] || bundle config set --local without "$BUNDLE_WITHOUT"
RUN bundle config set --local jobs "$(nproc)"
RUN bundle install
ARG RAILS_ENV
ENV RAILS_ENV="${RAILS_ENV:-production}" \
PATH="${PATH}:/home/ruby/.local/bin" \
USER="ruby" \
REDIS_URL="${REDIS_URL:-redis://notset/}"
COPY --chown=ruby:ruby . .
FROM base AS app
ENV RAILS_ENV="${RAILS_ENV:-production}" \
PATH="${PATH}:/home/ruby/.local/bin" \
USER="ruby"
WORKDIR /app
RUN apk update
RUN apk upgrade --available
RUN apk add libc6-compat openssl-dev libpq
RUN adduser -D ruby
RUN chown ruby:ruby -R /app
USER ruby
COPY --chown=ruby:ruby bin/ ./bin
RUN chmod 0755 bin/*
COPY --chown=ruby:ruby --from=build /usr/local/bundle /usr/local/bundle
COPY --chown=ruby:ruby --from=build /app /app
EXPOSE 9292
CMD ["/bin/sh", "-o", "xtrace", "-c", "rails s -b 0.0.0.0 -p 9292"]