-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (39 loc) · 1.19 KB
/
Dockerfile
File metadata and controls
48 lines (39 loc) · 1.19 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
# Set Ruby version for the container
ARG RUBY_VERSION=4.0.0
FROM ruby:$RUBY_VERSION-slim
# Set Ruby environment variables
ARG BUNDLE_PATH=/usr/local/bundle
ARG BUNDLER_VERSION=4.0.3
ARG RACK_ENV=production
ARG BUNDLE_WITHOUT="development:test"
ARG PORT=9292 # rackup default
# Install system dependencies
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
ca-certificates \
build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
/usr/share/doc \
/usr/share/man \
/var/cache/apt/archives
# Set working directory
WORKDIR /app
# Create log and tmp directories (for future use)
# RUN mkdir -p /app/log /app/tmp
# Set app environment variables
ENV RACK_ENV=${RACK_ENV} \
BUNDLE_PATH=${BUNDLE_PATH} \
BUNDLE_WITHOUT=${BUNDLE_WITHOUT}
# Install app dependencies
RUN gem install bundler:$BUNDLER_VERSION
COPY .ruby-version Gemfile Gemfile.lock ./
RUN bundle install \
&& rm -rf "${BUNDLE_PATH}"/ruby/*/cache \
"${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git
# Copy the rest of the application
COPY . .
# Expose app TCP port
EXPOSE $PORT
# Run Sinatra Rack app, intentionally overrideable from the command line
CMD ["bundle", "exec", "rackup", "-o", "0.0.0.0"]