Commit e3a7b93

mo <mo.khan@gmail.com>
2018-10-20 02:34:44
shrink docker image
1 parent 177e128
Changed files (2)
bin/docker-build
@@ -8,9 +8,9 @@ FULL_NAME=$(ls pkg/*.tar.gz | xargs basename | cut -d'.' -f1)
 NAME=$(echo "$FULL_NAME" | cut -d'-' -f1)
 VERSION=$(echo "$FULL_NAME" | cut -d'-' -f2)
 
-docker pull ruby:2.5
+sudo docker pull ruby:2.5.3-alpine
 echo "Building..." $NAME:$VERSION
-docker image build \
+sudo docker image build \
   -t "$NAME":"$VERSION" \
   -t "$NAME":latest \
   -f Dockerfile pkg/
Dockerfile
@@ -1,10 +1,15 @@
-FROM ruby:2.5
+FROM ruby:2.5.3-alpine
 ENV RAILS_ENV production
-RUN useradd rails
+ENV RAILS_LOG_TO_STDOUT true
+ENV RAILS_SERVE_STATIC_FILES true
+ENV PACKAGES build-base sqlite-dev libxml2-dev tzdata postgresql-dev
+RUN apk update && apk upgrade && apk add $PACKAGES && rm -fr /var/cache/apk/*
 ADD *.tar.gz .
-RUN ln -s /proof-* /app && chown -R rails:rails /app/
+RUN ln -s /proof-* /app
 WORKDIR /app
-RUN bundle install --without development test --jobs "$(nproc)" --quiet # --local
+RUN bundle install --deployment --jobs "$(nproc)" --local
+RUN apk del build-base
+RUN adduser -D -u 1000 rails && chown -R rails:rails /app/
 USER rails
 ENTRYPOINT ["bundle", "exec"]
 CMD ["foreman", "start"]