-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
52 lines (39 loc) · 1.2 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
# The first stage is dedicated to building the application
FROM ruby:3.2.2-alpine AS build
ENV PORT=9594 \
USER=app \
GROUP=appgroup \
ROOT=/srv
WORKDIR $ROOT
# Update system packages and installing dependencies
RUN apk update && apk upgrade && \
apk add --update --no-cache --virtual .build-deps \
build-base \
libffi-dev \
ruby-dev
# Copy the Gemfile and Gemfile.lock
COPY Gemfile Gemfile.lock $ROOT/
# Run the specific version of bundle to install all the necessary libraries
RUN gem install bundler && \
bundle install && \
apk del .build-deps && \
rm -rf /usr/local/bundle/cache/*.gem && \
find /usr/local/bundle/gems/ -name "*.c" -delete && \
find /usr/local/bundle/gems/ -name "*.o" -delete
COPY . $ROOT/
# The second stage is responsible for preparing the runtime
FROM ruby:3.2.2-alpine AS runtime
# Copy over files from the build step
COPY --from=build $ROOT $ROOT
# Set environmental variables
ENV PORT=9594 \
USER=app \
GROUP=appgroup \
ROOT=/srv
WORKDIR $ROOT
RUN addgroup -S $GROUP && \
adduser -S $USER -G $GROUP && \
chown -R $USER:$GROUP $ROOT && \
chmod 755 config.ru
USER $USER:$GROUP
CMD bundle exec puma -b tcp://0.0.0.0:$PORT