Ngày đăng
Dec 29, 2023 1:02 AM
Tác giả
Quân Huỳnh
Dockerfile for other programing language
Without assets:
FROM ruby:3.2-slim-bullseye
# Install system dependencies required both at runtime and build time
RUN apt-get update && apt-get install -y \
build-essential \
# example system dependencies that need for "gem install pg"
libpq-dev
COPY Gemfile Gemfile.lock ./
# Install (excluding development/test dependencies)
RUN gem install bundler && \
bundle config set without "development test" && \
bundle install
COPY . .
CMD ["rails", "server", "-b", "0.0.0.0"]
With assets:
FROM ruby:3.2-slim-bullseye
# Install system dependencies required both at runtime and build time
RUN apt-get update && apt-get install -y \
build-essential \
# example system dependencies that need for "gem install pg"
libpq-dev \
nodejs \
yarn
COPY Gemfile Gemfile.lock ./
# Install (excluding development/test dependencies)
RUN gem install bundler && \
bundle config set without "development test" && \
bundle install
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
# Install assets
RUN RAILS_ENV=production SECRET_KEY_BASE=assets bundle exec rails assets:precompile
CMD ["rails", "server", "-b", "0.0.0.0"]
Note - On MacOS M Chip, maybe you need to add a flag --platform=linux/amd64
when build:
docker build . -t rubyonrails-app --platform=linux/amd64
Nếu bài viết có gì sai hoặc cần cập nhật thì liên hệ Admin.
Tham gia nhóm chat của DevOps VN tại Telegram.
Kém tiếng Anh và cần nâng cao trình độ giao tiếp: Tại sao bạn học không hiệu quả?