-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
52 lines (47 loc) · 1.53 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
46
47
48
49
50
51
52
# Base image
FROM ruby:3.3.4-slim-bookworm AS base
LABEL org.opencontainers.image.authors="pokorny@luk4s.cz"
# Setup environment variables that will be available to the instance
ENV RAILS_ROOT=/app
# Installation of dependencies
RUN apt update -qq \
&& apt install -y vim curl firefox-esr \
# Needed for certain gems
build-essential \
# Needed for postgres gem
libpq-dev \
# https://github.com/mimemagicrb/mimemagic
shared-mime-info \
# The following are used to trim down the size of the image by removing unneeded data
&& apt clean autoclean \
&& apt autoremove -y
RUN gem install bundler --no-document --version 2.5.22
# Create a directory for our application
# and set it as the working directory
WORKDIR "${RAILS_ROOT}"
# Add our Gemfile
# and install gems
COPY Gemfile* ./
RUN bundle config set deployment 'true' && \
bundle install --no-cache --jobs $(nproc) --retry 5
FROM base AS assets
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
RUN apt update && \
apt install -y nodejs && \
corepack enable && \
yarn set version classic
# Copy over our application code
COPY . .
RUN bundle exec rails assets:precompile
FROM base
ENV RAILS_ENV="production"
RUN ln -s "${RAILS_ROOT}/bin/geckodriver" /usr/local/bin/
COPY . .
COPY --from=assets /app/public /app/public
RUN useradd rails --create-home --shell /bin/bash && \
mkdir -p db log storage tmp coverage && \
chown -R rails:rails db log storage tmp coverage
USER rails:rails
EXPOSE 3000/tcp
ENTRYPOINT ["./bin/docker-entrypoint.sh"]
CMD ["start"]