-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
46 lines (35 loc) · 1.2 KB
/
Dockerfile
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
# Use the official Ruby image with version 3.2.0
FROM ruby:3.2.0
# Install dependencies
RUN apt-get update -qq && apt-get install -y \
nodejs \
postgresql-client \
libssl-dev \
libreadline-dev \
zlib1g-dev \
build-essential \
curl
# Install rbenv
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv && \
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc && \
echo 'eval "$(rbenv init -)"' >> ~/.bashrc && \
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build && \
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
# Install the specified Ruby version using rbenv
ENV PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH"
RUN rbenv install 3.2.0 && rbenv global 3.2.0
# Set the working directory
WORKDIR /myapp
# Copy the Gemfile and Gemfile.lock
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
# Install Gems dependencies
RUN gem install bundler && bundle install
# Copy the application code
COPY . /myapp
# Precompile assets (optional, if using Rails with assets)
RUN bundle exec rake assets:precompile
# Expose the port the app runs on
EXPOSE 3000
# Command to run the server
CMD ["rails", "server", "-b", "0.0.0.0"]