60 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Docker
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			Docker
		
	
	
		
			Executable File
		
	
	
	
	
| ARG BASE_IMAGE=wizewerx/rr-alpine-base:latest
 | |
| ARG GEM_CACHE=${BASE_IMAGE}
 | |
| 
 | |
| FROM $GEM_CACHE AS gems-cache
 | |
| RUN mkdir -p /usr/local/bundle
 | |
| 
 | |
| FROM $BASE_IMAGE as base
 | |
| WORKDIR /app
 | |
| 
 | |
| FROM base as gems
 | |
| WORKDIR /app
 | |
| ENV RAILS_ROOT /app
 | |
| ENV RAILS_LOG_TO_STDOUT true
 | |
| ENV RAILS_ENV production
 | |
| ENV BUNDLE_PATH=/usr/local/bundle
 | |
| RUN apk add --no-cache \
 | |
|     postgresql-dev \
 | |
|     git \
 | |
|     ruby-dev \
 | |
|     && rm -rf /var/cache/apk/*
 | |
| COPY --from=gems-cache /usr/local/bundle /usr/local/bundle
 | |
| COPY Gemfile ./
 | |
| COPY Gemfile.lock ./
 | |
| COPY package.json ./
 | |
| COPY yarn.lock ./
 | |
| ENV BUNDLE_GIT__WIZEWERX__TECH mike:bd94eefdabc2dcbe0db2a715715751e801fff9e0
 | |
| RUN bundle config set deployment 'true' && \
 | |
|     bundle install --jobs 30 --retry 5 && \
 | |
|     rm -rf /usr/local/bundle/cache/*.gem && \
 | |
|     find /usr/local/bundle/gems/ -name "*.c" -delete && \
 | |
|     find /usr/local/bundle/gems/ -name "*.o" -delete
 | |
| 
 | |
| 
 | |
| FROM base as final
 | |
| WORKDIR /app
 | |
| ENV RAILS_ROOT /app
 | |
| ENV RAILS_LOG_TO_STDOUT true
 | |
| ENV RAILS_ENV production
 | |
| ENV BUNDLE_PATH=/usr/local/bundle
 | |
| ## Copy app with gems from former build stage
 | |
| COPY --from=gems /usr/local/bundle /usr/local/bundle
 | |
| ADD . .
 | |
| RUN apk add postgresql-client \
 | |
|     imagemagick \
 | |
|     ffmpeg\
 | |
|     curl \
 | |
|     bash \
 | |
|     && rm -rf /var/cache/apk/* \
 | |
|     && RAILS_ENV=production SECRET_KEY_BASE=_ bundle exec rake DATABASE_URL=nulldb:db_shim assets:precompile && \
 | |
|     rm -rf spec node_modules tmp/cache
 | |
| EXPOSE 3000
 | |
| CMD bundle exec rake db:migrate && VIA_SERVER=true bundle exec rails s
 | |
| 
 | |
| ## without cache
 | |
| # APP=wizewerx/betbeast && TARGET=master && docker build -f ./docker/Dockerfile -t $APP:$TARGET . && docker push $APP:$TARGET
 | |
| 
 | |
| # with cache
 | |
| # APP=wizewerx/betbeast && TARGET=master && docker build --cache-from $APP:$TARGET -f ./docker/Dockerfile -t $APP:$TARGET . && docker push $APP:$TARGET
 | |
| # APP=wizewerx/betbeast && TARGET=master docker push $APP:$TARGET
 |