36 lines
1.1 KiB
Docker
36 lines
1.1 KiB
Docker
FROM ruby:2.7.8
|
|
|
|
RUN apt-get update -qq && \
|
|
curl -sL https://deb.nodesource.com/setup_16.x | bash - && \
|
|
apt-get install -y build-essential libpq-dev nodejs curl gnupg && \
|
|
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
|
|
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
|
|
apt-get update -qq && apt-get install -y yarn && \
|
|
useradd --user-group --create-home --shell /bin/false app
|
|
|
|
ENV HOME=/home/app
|
|
# After setting WORKDIR and USER app
|
|
WORKDIR $HOME/wedding
|
|
# Create node_modules owned by app
|
|
RUN mkdir -p node_modules && chown -R app:app node_modules
|
|
|
|
USER app
|
|
|
|
# Copy Gemfiles and install Ruby deps
|
|
COPY --chown=app:app Gemfile Gemfile.lock ./
|
|
RUN bundle install
|
|
|
|
# Copy the rest of the app
|
|
COPY --chown=app:app . ./
|
|
|
|
# Ensure node_modules directory is owned by app
|
|
RUN mkdir -p node_modules && chmod -R 755 node_modules
|
|
|
|
# Install JS deps before assets:precompile
|
|
RUN yarn install --check-files
|
|
|
|
# Compile assets
|
|
RUN bundle exec rake assets:precompile
|
|
|
|
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
|