1- # Use Ruby 3.2 Alpine image for smaller size
2- FROM ruby:3.1.7-alpine
3-
4- # Install system dependencies
5- RUN apk add --no-cache \
6- build-base \
7- postgresql-dev \
8- git \
9- tzdata \
10- nodejs \
11- yarn
12-
13- # Set working directory
14- WORKDIR /app
15-
16- # Copy Gemfile (and Gemfile.lock if it exists)
17- COPY Gemfile ./
18- COPY Gemfile.lock* ./
19-
20- # Install Ruby dependencies
21- RUN bundle install --jobs 4 --retry 3
22-
23- # Copy application code
24- COPY . .
25-
26- # Create user to run the application
27- RUN addgroup -g 1000 -S app && \
28- adduser -u 1000 -S app -G app
29-
30- # Change ownership of the app directory
31- RUN chown -R app:app /app
32-
33- # Switch to the app user
34- USER app
35-
36- # Expose port 3333
37- EXPOSE 3333
38-
39- # Health check
40- HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
41- CMD curl -f http://localhost:3333/up || exit 1
42-
43- # Start the Rails server
1+ # Use Ruby 3.4.5 slim image (better Windows compatibility)
2+ FROM ruby:3.4.5-slim
3+
4+ # Install system dependencies
5+ RUN apt-get update -qq && apt-get install -y \
6+ build-essential \
7+ libpq-dev \
8+ libyaml-dev \
9+ git \
10+ tzdata \
11+ nodejs \
12+ npm \
13+ curl \
14+ && npm install -g yarn \
15+ && rm -rf /var/lib/apt/lists/*
16+
17+ # Set working directory
18+ WORKDIR /app
19+
20+ # Copy Gemfile (and Gemfile.lock if it exists)
21+ COPY Gemfile ./
22+ COPY Gemfile.lock* ./
23+
24+ # Install Ruby dependencies
25+ RUN bundle install --jobs 4 --retry 3
26+
27+ # Copy application code
28+ COPY . .
29+
30+ # Create user to run the application
31+ RUN groupadd -g 1000 app && \
32+ useradd -u 1000 -g app -m -s /bin/bash app
33+
34+ # Change ownership of the app directory
35+ RUN chown -R app:app /app
36+
37+ # Switch to the app user
38+ USER app
39+
40+ # Expose port 3333
41+ EXPOSE 3333
42+
43+ # Health check
44+ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
45+ CMD curl -f http://localhost:3333/up || exit 1
46+
47+ # Start the Rails server
4448CMD ["bundle" , "exec" , "rails" , "server" , "-b" , "0.0.0.0" ]
0 commit comments