parsley/Dockerfile
2020-01-18 18:07:07 -06:00

52 lines
1.5 KiB
Docker

FROM phusion/passenger-ruby26:1.0.9
# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]
# Install Node
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list && \
apt-get update && \
apt-get -y dist-upgrade && \
apt-get install -y --no-install-recommends yarn nodejs && \
apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN gem update --system && gem install bundler
# Enable Nginx / Passenger
RUN rm -f /etc/service/nginx/down
# Install nginx config files
RUN rm /etc/nginx/sites-enabled/default
ADD docker/nginx_server.conf /etc/nginx/sites-enabled/parsley.conf
ADD docker/nginx_env.conf /etc/nginx/main.d/env.conf
# Add DB Migration Script
RUN mkdir -p /etc/my_init.d
ADD docker/db_migrate.sh /etc/my_init.d/db_migrate.sh
RUN chmod +x /etc/my_init.d/db_migrate.sh
# Set Default RAILS_ENV
ENV RAILS_ENV docker
ENV PASSENGER_APP_ENV docker
# Setup directory and install gems
RUN mkdir -p /home/app/parsley/log /home/app/parsley/tmp
RUN chown -R app:app /home/app/parsley/
WORKDIR /home/app/parsley/
COPY Gemfile* ./
RUN su app -c "bundle install --deployment --jobs 4 --without development test"
COPY package.json yarn.lock ./
RUN su app -c "yarn install --production=true --frozen-lockfile"
# Copy the app into the image
COPY --chown="app" . .
# Compile assets
RUN su app -c "bundle exec rails webpacker:clobber webpacker:compile"