-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (38 loc) · 1.25 KB
/
Dockerfile
File metadata and controls
49 lines (38 loc) · 1.25 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
# Use Ruby 3.4.5 slim image (better Windows compatibility)
FROM ruby:3.4.5-slim
# Install system dependencies without version pinning for compatibility
# Note: Using latest available versions from Debian repositories
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
libyaml-dev \
git \
tzdata \
nodejs \
npm \
curl \
&& npm install -g yarn@1.22.22 \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy Gemfile (and Gemfile.lock if it exists)
COPY Gemfile ./
COPY Gemfile.lock* ./
# Install Ruby dependencies
RUN bundle install --jobs 4 --retry 3
# Copy application code
COPY . .
# Create user to run the application
RUN groupadd -g 1000 app && \
useradd -u 1000 -g app -m -s /bin/bash app
# Change ownership of the app directory and bundle directory
RUN chown -R app:app /app /usr/local/bundle
# Switch to the app user
USER app
# Expose port 3000 (Rails default)
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
# Start the Rails server
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]