Created
July 23, 2019 20:56
-
-
Save webchi/b168183638789fa0cd17fb7760a80acd to your computer and use it in GitHub Desktop.
Rails multistage mariadb alpine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ruby:2.5.5-alpine3.9 as builder | |
WORKDIR /app | |
ENV BUNDLE_SILENCE_ROOT_WARNING=1 \ | |
BUNDLE_IGNORE_MESSAGES=1 \ | |
BUNDLE_GITHUB_HTTPS=1 \ | |
BUNDLE_FROZEN=1 \ | |
BUNDLE_WITHOUT=development:test | |
RUN apk update && apk add --no-cache \ | |
build-base mariadb-dev nodejs tzdata | |
COPY Gemfile* ./ | |
RUN gem install bundler && bundle install -j4 --retry 3 | |
# Add the Rails app | |
COPY . /app | |
RUN bundle exec rake assets:precompile RAILS_ENV=production && \ | |
mv ./config/database_docker.yml ./config/database.yml && \ | |
mv ./config/secrets_sample.yml ./config/secrets.yml | |
FROM ruby:2.5.5-alpine3.9 | |
ENV RAILS_ENV=production | |
WORKDIR /app | |
COPY --from=builder /usr/local/bundle /usr/local/bundle | |
COPY --from=builder /app ./ | |
RUN apk update && apk add --no-cache \ | |
mariadb-connector-c tzdata nodejs && \ | |
addgroup -g 1000 -S appuser && \ | |
adduser -u 1000 -S appuser -G appuser && \ | |
chown appuser:appuser /app -R | |
EXPOSE 3000 | |
USER appuser | |
CMD ["ruby", "init.rb"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment