WIP de docker, falla el bundler
This commit is contained in:
parent
3d489c0a0f
commit
5d87144a98
3 changed files with 116 additions and 0 deletions
19
.dockerignore
Normal file
19
.dockerignore
Normal file
|
@ -0,0 +1,19 @@
|
|||
Dockerfile
|
||||
node_modules/
|
||||
tmp/
|
||||
log/
|
||||
public/
|
||||
docs/
|
||||
bin/
|
||||
db/
|
||||
lib/
|
||||
test/
|
||||
tmp/
|
||||
vendor/
|
||||
config.ru
|
||||
LICENSE
|
||||
Makefile
|
||||
monit.conf
|
||||
README.md
|
||||
TODO*
|
||||
web@.service
|
72
Dockerfile
Normal file
72
Dockerfile
Normal file
|
@ -0,0 +1,72 @@
|
|||
FROM alpine:3.9 AS build
|
||||
ENV PACKAGER "fauno <fauno@lainventoria.com.ar>"
|
||||
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
|
||||
RUN apk add --no-cache git nodejs nodejs-npm yarn \
|
||||
postgresql-libs postgresql-dev tzdata libxslt libxslt-dev \
|
||||
libxml2 libxml2-dev alpine-sdk
|
||||
RUN apk add --no-cache ruby-dev ruby-bundler ruby-json ruby-bigdecimal ruby-rake
|
||||
# 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
|
||||
|
||||
# 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
|
||||
COPY --chown=app:www-data ./app/assets ./app/assets
|
||||
# Pre-compilar los assets
|
||||
COPY --chown=app:www-data ./Rakefile .
|
||||
COPY --chown=app:www-data ./config/ ./config/
|
||||
COPY --chown=app:www-data ./app/ ./app/
|
||||
#COPY --chown=app:www-data ./yarn.lock .
|
||||
COPY --chown=app:www-data ./package.json .
|
||||
RUN yarn
|
||||
RUN bundle exec rake assets:precompile
|
||||
|
||||
FROM lunar/monit:3.9
|
||||
RUN apk add --no-cache libxslt libxml2 tzdata ruby ruby-bundler ruby-json ruby-bigdecimal ruby-rake
|
||||
RUN apk add --no-cache postgresql-libs
|
||||
RUN addgroup -g 82 -S www-data
|
||||
RUN apk add --no-cache darkhttpd
|
||||
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 los assets compilados
|
||||
COPY --from=build --chown=app:www-data /home/app/web/public/assets public/assets
|
||||
# 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
|
||||
# Y el .env
|
||||
COPY ./.env ./.env
|
||||
# Eliminar la necesidad de un runtime JS en producción, porque los
|
||||
# assets ya están pre-compilados
|
||||
RUN sed -re "/(uglifier|bootstrap|coffee-rails)/d" -i Gemfile
|
||||
RUN bundle clean
|
||||
|
||||
USER root
|
||||
RUN install -m 640 -o root -g root ./monit.conf /etc/monit.d/puma.conf
|
||||
RUN monit -t
|
||||
VOLUME "/srv/http/public/system"
|
||||
EXPOSE 3000
|
25
Makefile
Normal file
25
Makefile
Normal file
|
@ -0,0 +1,25 @@
|
|||
.DEFAULT_GOAL := all
|
||||
|
||||
d ?= api
|
||||
c ?= $(shell date +%F | tr "-" ".")
|
||||
r ?= $(shell git rev-list --count HEAD)
|
||||
name = miniloom/$(d):$(c).$(r)
|
||||
|
||||
clean:
|
||||
rm -f log/*.log
|
||||
rm -rf tmp/cache/assets
|
||||
|
||||
build:
|
||||
docker build -t $(name) .
|
||||
|
||||
tag:
|
||||
git tag $(c).$(r)
|
||||
docker tag $(name) miniloom/$(d):latest
|
||||
docker tag $(name) registry.forja.lainventoria.com.ar/$(name)
|
||||
docker tag $(name) registry.forja.lainventoria.com.ar/miniloom/$(d):latest
|
||||
|
||||
push:
|
||||
docker push registry.forja.lainventoria.com.ar/$(name)
|
||||
docker push registry.forja.lainventoria.com.ar/miniloom/$(d):latest
|
||||
|
||||
all: clean build tag push
|
Loading…
Reference in a new issue