-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.dev
More file actions
81 lines (62 loc) · 2.21 KB
/
Dockerfile.dev
File metadata and controls
81 lines (62 loc) · 2.21 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# syntax=docker/dockerfile:1
# Development Dockerfile for WeatherForge
# Optimized for rapid development with volume mounts and hot reloading
ARG RUBY_VERSION=3.4.5
ARG NODE_VERSION=22.12.0
FROM ruby:${RUBY_VERSION}-slim
# Set build args for this stage
ARG NODE_VERSION=22.12.0
ARG USER_ID=1000
ARG GROUP_ID=1000
# Install system dependencies for development
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y \
build-essential \
curl \
git \
libpq-dev \
libvips \
libyaml-dev \
node-gyp \
pkg-config \
postgresql-client \
python-is-python3 \
vim \
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Install Node.js for JavaScript bundling
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ && \
/tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node && \
rm -rf /tmp/node-build-master
# Set working directory
WORKDIR /rails
# Set development environment
ENV RAILS_ENV=development \
BUNDLE_PATH=/usr/local/bundle \
NODE_ENV=development
# Create non-root user matching host user ID to avoid permission issues
# This will be overridden by docker-compose if USER_ID/GROUP_ID are provided
RUN groupadd --gid ${GROUP_ID} rails || true && \
useradd --uid ${USER_ID} --gid ${GROUP_ID} --create-home --shell /bin/bash rails || true && \
mkdir -p /rails/tmp /rails/log /rails/storage && \
chown -R ${USER_ID}:${GROUP_ID} /rails /usr/local/bundle
# Switch to non-root user
USER ${USER_ID}:${GROUP_ID}
# Install bundler
RUN gem install bundler -v '~> 2.6'
# Copy dependency files first (for layer caching)
COPY --chown=${USER_ID}:${GROUP_ID} Gemfile Gemfile.lock ./
# Install gems with full build tools available
RUN bundle install
# Copy package files
COPY --chown=${USER_ID}:${GROUP_ID} package.json package-lock.json ./
# Install node modules
RUN npm ci
# Copy application code
COPY --chown=${USER_ID}:${GROUP_ID} . .
# Precompile bootsnap for faster boot times
RUN bundle exec bootsnap precompile --gemfile app/ lib/ || true
# Expose port 3000
EXPOSE 3000
# Default command (can be overridden by docker-compose)
CMD ["bin/rails", "server", "-b", "0.0.0.0"]