Skip to content

Commit

Permalink
update docker setup (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
klausmeyer committed Apr 25, 2024
1 parent 34fcdca commit bd5b7f2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 21 deletions.
44 changes: 25 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
FROM ruby:3.3.1-alpine

MAINTAINER Klaus Meyer <spam@klaus-meyer.net>
LABEL maintainer="Klaus Meyer <spam@klaus-meyer.net>"

ARG SOURCE_COMMIT
ENV SOURCE_COMMIT $SOURCE_COMMIT

ENV PORT 8080
ENV SSL_PORT 8443
ENV RAILS_ENV production
ENV SECRET_KEY_BASE changeme
ENV RAILS_SERVE_STATIC_FILES true
ENV RAILS_LOG_TO_STDOUT true

EXPOSE $PORT
EXPOSE $SSL_PORT

WORKDIR /app

ADD . .
ENTRYPOINT ["/docker-entrypoint.sh"]

RUN apk update \
&& apk add build-base zlib-dev tzdata git openssl-dev shared-mime-info postgresql-dev libc6-compat vips-dev \
&& rm -rf /var/cache/apk/* \
&& gem install bundler -v $(tail -n1 Gemfile.lock | xargs) \
&& bundle config set build.sassc '--disable-march-tune-native' \
&& bundle config set without 'development test' \
&& bundle install \
&& bundle exec rails assets:precompile \
&& addgroup -S app && adduser -S app -G app -h /app \
&& chown -R app.app /app \
&& chown -R app.app /usr/local/bundle

USER app

CMD puma -C config/puma.rb
&& mkdir -p /var/www/rails

COPY Gemfile Gemfile.lock /var/www/rails/
COPY docker-entrypoint.sh /docker-entrypoint.sh

WORKDIR /var/www/rails/

RUN gem install bundler -v $(grep -A1 "BUNDLED WITH" Gemfile.lock | tail -n1 | tr -d "[:space:]") \
&& bundle config set build.sassc "--disable-march-tune-native" \
&& bundle config set without "development test" \
&& bundle install

ADD . /var/www/rails/

RUN SECRET_KEY_BASE=dummyvalue bundle exec rails assets:precompile

RUN addgroup -S rails && adduser -S rails -G rails -h /var/www/rails/ \
&& chown -R rails.rails /var/www/rails/ \
&& chown -R rails.rails /usr/local/bundle

USER rails

CMD ["web"]
2 changes: 0 additions & 2 deletions Procfile

This file was deleted.

15 changes: 15 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -e

case "$1" in
web)
bundle exec rails db:prepare

exec bundle exec puma -C config/puma.rb
;;

*)
exec $@
;;
esac

0 comments on commit bd5b7f2

Please sign in to comment.