-
-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (25 loc) · 921 Bytes
/
Dockerfile
File metadata and controls
39 lines (25 loc) · 921 Bytes
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
ARG RUBY_VERSION=3.4.4
FROM ruby:$RUBY_VERSION-alpine AS base
WORKDIR /stoplight
# Set production environment
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development"
FROM base AS build
RUN apk --update --no-cache add build-base
COPY Gemfile Gemfile.lock stoplight.gemspec ./
COPY lib/stoplight/version.rb ./lib/stoplight/version.rb
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git
COPY . .
FROM base
# Copy built artifacts: gems, application
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=build /stoplight /stoplight
# Run and own only the runtime files as a non-root user for security
RUN addgroup --g 1000 -S stoplight && \
adduser -u 1000 -D -S -G stoplight stoplight
USER 1000:1000
EXPOSE 4567
CMD ["bundle", "exec", "puma", "-p", "4567"]