-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
55 lines (37 loc) · 1.36 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
# syntax = docker/dockerfile:1.4
################# dependencies ##############
FROM ruby:3.1.2-alpine AS dependencies
# Install system dependencies required to build some Ruby gems (pg)
RUN apk add --update --no-cache \
build-base
COPY Gemfile Gemfile.lock ./
# Install gems (excluding development/test dependencies)
RUN --mount=type=cache,target=/usr/local/bundle/cache \
bundle config set without "development test" && \
bundle install --jobs=5 --retry=5
################# runtime ####################
FROM ruby:3.1.2-alpine AS runtime
ENV TZ=Asia/Seoul
ENV RACK_ENV=production
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk add --update --no-cache \
tzdata \
kubectl \
jq
# Create a non-root user to run the app and own app-specific files
RUN adduser -D app
# Switch to this user
USER app
# We'll install the app in this directory
WORKDIR /home/app
# Copy over gems from the dependencies stage
COPY --from=dependencies /usr/local/bundle/ /usr/local/bundle/
# Copy rackup files
COPY --chown=app Gemfile Gemfile.lock config.ru ./
# Copy config files
COPY --chown=app config ./config
# Copy src files
COPY --chown=app src ./src
# Launch the server
CMD ["bundle", "exec", "puma", "-t", "8:32"]