-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
39 lines (27 loc) · 863 Bytes
/
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
# Backend - Rails API
# Use the official Ruby image as the base image
FROM ruby:3.0.0
# Set the working directory in the container
WORKDIR ./backend
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Install bundler
RUN gem install bundler
# Copy Gemfile and Gemfile.lock
COPY Gemfile Gemfile.lock ./
# Install gems
RUN bundle install --jobs 4 --retry 3
# Copy the rest of the application code
COPY . .
# Expose the port on which the Rails app will run
EXPOSE 3000
# Set environment variables for the Rails API
ENV RAILS_ENV production
ENV RAILS_LOG_TO_STDOUT true
ENV DATABASE_URL $DATABASE_URL
# Precompile assets
RUN bundle exec rails assets:precompile
# Run database migrations
RUN bundle exec rails db:migrate
# Start the Rails server
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]