-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
92 lines (66 loc) · 2.2 KB
/
Dockerfile
File metadata and controls
92 lines (66 loc) · 2.2 KB
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
91
92
# syntax=docker/dockerfile:1.3.0-labs
ARG GEM_HOME="/app/vendor/bundle"
ARG RAILS_ENV="production"
ARG BUNDLE_DEPLOYMENT=1
ARG BUNDLE_WITHOUT="development test"
ARG PACKAGES_COMMON=" \
libc6-compat \
nodejs \
"
ARG PACKAGES_BUILD=" \
build-base \
npm \
postgresql-dev \
"
ARG PACKAGES_RUN=" \
curl \
file \
postgresql-client \
tzdata \
"
### Builder Stage ###
FROM public.ecr.aws/docker/library/ruby:3.0.6-alpine3.16 AS builder
ARG BUNDLE_DEPLOYMENT
ARG BUNDLE_WITHOUT
ARG GEM_HOME
ARG PACKAGES_COMMON
ARG PACKAGES_BUILD
ARG RAILS_ENV
ENV PATH="/app/vendor/bundle/bin:/app/vendor/bundle/gems/bin:${PATH}"
RUN apk add --update --virtual .build-deps ${PACKAGES_COMMON} ${PACKAGES_BUILD}
RUN npm install -g yarn
RUN gem install bundler:2.4.22
COPY . /app
WORKDIR /app
RUN \
MAKE="make --jobs 8" \
bundle install -j8
# Remove unneeded files (cached *.gem, *.o, *.c)
# Handle variations in Bundle path for gems
RUN find /app/vendor/bundle -path /app/vendor/bundle/gems/ -name "*.c" -delete
RUN find /app/vendor/bundle -path /app/vendor/bundle/gems/ -name "*.o" -delete
RUN find /app/vendor/bundle -path /app/vendor/bundle/cache/ -name "*.gem" -delete
RUN find /app/vendor/bundle -path /app/vendor/bundle/ruby/*/gems/ -name "*.c" -delete
RUN find /app/vendor/bundle -path /app/vendor/bundle/ruby/*/gems/ -name "*.o" -delete
RUN find /app/vendor/bundle -path /app/vendor/bundle/ruby/*/cache/ -name "*.gem" -delete
RUN rm -rf node_modules tmp/cache/* spec
### Build Complete ###
# Final Image
FROM public.ecr.aws/docker/library/ruby:3.0.6-alpine3.16
ARG GEM_HOME
ARG PACKAGES_COMMON
ARG PACKAGES_RUN
ENV BUNDLE_APP_CONFIG="/app/vendor/bundle"
ENV BUNDLE_BIN="/app/vendor/bundle/bin"
ENV BUNDLE_PATH="/app/vendor/bundle"
ENV GEM_HOME="/app/vendor/bundle"
ENV PATH="/app/vendor/bundle/bin:/app/vendor/bundle/gems/bin:${PATH}"
RUN apk add --update --virtual .app-deps ${PACKAGES_COMMON} ${PACKAGES_RUN}
RUN addgroup --gid 5000 demo \
&& adduser --home /app --uid 5000 --disabled-password --no-create-home \
--ingroup demo --shell /bin/sh --skel /dev/null demo
COPY --from=builder --chown=demo:demo /app /app
USER demo
WORKDIR /app
VOLUME /var/lib/docker
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]