2019-04-05 22:44:06 +00:00
|
|
|
FROM alpine:3.9 AS build
|
2019-04-06 19:46:19 +00:00
|
|
|
ENV PACKAGER "fauno <fauno@partidopirata.com.ar>"
|
2019-04-05 22:44:06 +00:00
|
|
|
ENV NOKOGIRI_USE_SYSTEM_LIBRARIES=1
|
|
|
|
ENV SECRET_KEY_BASE solo_es_necesaria_para_correr_rake
|
|
|
|
ENV RAILS_ENV production
|
|
|
|
|
|
|
|
# Instalar las herramientas para instalar las gemas y paquetes
|
2019-04-06 19:46:19 +00:00
|
|
|
RUN apk add --no-cache git tzdata libxslt libxslt-dev libxml2 libxml2-dev alpine-sdk
|
2019-04-06 20:51:42 +00:00
|
|
|
RUN apk add --no-cache ruby-dev ruby-json ruby-bigdecimal ruby-rake
|
2019-04-06 19:46:19 +00:00
|
|
|
RUN apk add --no-cache sqlite sqlite-dev
|
2019-04-05 22:44:06 +00:00
|
|
|
# Crear una usuaria de trabajo, más que nada para que bundler no se
|
|
|
|
# queje que estamos corriendo como root
|
|
|
|
RUN addgroup -g 82 -S www-data
|
|
|
|
RUN adduser -s /bin/sh -G www-data -h /home/app -D app
|
|
|
|
RUN install -dm 2750 -o app -g www-data /home/app/web
|
2019-04-06 19:46:19 +00:00
|
|
|
RUN gem install --no-user-install --no-ri --no-rdoc bundler
|
2019-04-05 22:44:06 +00:00
|
|
|
|
|
|
|
# find | xargs es más rápido que un chown recursivo
|
|
|
|
USER app
|
|
|
|
WORKDIR /home/app/web
|
|
|
|
COPY --chown=app:www-data ./Gemfile .
|
|
|
|
COPY --chown=app:www-data ./Gemfile.lock .
|
|
|
|
# Instalar las gemas de producción
|
|
|
|
RUN bundle install --path=./vendor --without test development
|
|
|
|
# Eliminar cosas que ya no sirven
|
|
|
|
RUN rm vendor/ruby/2.5.0/cache/*.gem
|
|
|
|
# Limpiar las librerías nativas
|
|
|
|
RUN find vendor -name "*.so" | xargs -rn 1 strip --strip-unneeded
|
|
|
|
COPY --chown=app:www-data ./.git/ ./.git/
|
|
|
|
# Hacer un tarball de los archivos de la web
|
|
|
|
RUN git archive -o ../web.tar.gz HEAD
|
|
|
|
|
|
|
|
FROM lunar/monit:3.9
|
2019-04-06 21:06:07 +00:00
|
|
|
RUN apk add --no-cache libxslt libxml2 tzdata ruby ruby-json ruby-bigdecimal ruby-rake ruby-etc
|
2019-04-06 20:51:42 +00:00
|
|
|
RUN apk add --no-cache sqlite-libs
|
2019-04-06 20:41:44 +00:00
|
|
|
RUN apk add --no-cache darkhttpd
|
2019-04-06 20:51:42 +00:00
|
|
|
RUN gem install --no-user-install --no-ri --no-rdoc bundler
|
2019-04-05 22:44:06 +00:00
|
|
|
COPY ./entrypoint.sh /usr/bin/entrypoint
|
|
|
|
RUN chmod 755 /usr/bin/entrypoint
|
|
|
|
# Agregar el usuario
|
|
|
|
RUN adduser -s /bin/sh -G www-data -h /srv/http -D app
|
|
|
|
# Traer los archivos de la web y colocarlos donde van definitivamente
|
|
|
|
USER app
|
|
|
|
COPY --from=build --chown=app:www-data /home/app/web.tar.gz /tmp/
|
|
|
|
WORKDIR /srv/http
|
|
|
|
RUN tar xf /tmp/web.tar.gz && rm /tmp/web.tar.gz
|
|
|
|
# Traer las gemas
|
|
|
|
COPY --from=build --chown=app:www-data /home/app/web/vendor ./vendor
|
|
|
|
COPY --from=build --chown=app:www-data /home/app/web/.bundle ./.bundle
|
2019-04-06 20:41:44 +00:00
|
|
|
COPY --chown=app:www-data ./docs ./public/docs
|
2019-04-05 22:44:06 +00:00
|
|
|
|
|
|
|
USER root
|
|
|
|
RUN install -m 640 -o root -g root ./monit.conf /etc/monit.d/puma.conf
|
|
|
|
RUN monit -t
|
2019-04-06 20:41:44 +00:00
|
|
|
VOLUME "/srv/http/data"
|
2019-04-05 22:44:06 +00:00
|
|
|
EXPOSE 3000
|
2019-04-06 20:41:44 +00:00
|
|
|
EXPOSE 8080
|