Преглед на файлове

Only copy necessary files to docker container

Andrew Swistak преди 6 години
родител
ревизия
6d50f36989
променени са 1 файла, в които са добавени 34 реда и са изтрити 6 реда
  1. 34 6
      Dockerfile

+ 34 - 6
Dockerfile

@@ -23,17 +23,31 @@ COPY package.json yarn.lock /app/
 RUN yarn install && yarn cache clean
 
 # Copy our app over now
-COPY . /app
+#COPY . /app
+
+COPY bin/ /app/bin
+COPY .rspec .ruby-version Rakefile /app/
+COPY vendor/ /app/vendor
+COPY config.ru /app/config.ru
+COPY config/ /app/config
+#COPY config/database.yml.docker /app/config/database.yml
+COPY public/ /app/public
+COPY db/ /app/db
+COPY app/assets/ /app/app/assets
+COPY app/javascript/ /app/app/javascript
+COPY lib/ /app/lib
+#COPY app/ /app/app
+#COPY spec/ /app/spec
 
 # Copy the docker configuration to the correct location
-COPY config/database.yml.docker config/database.yml
+#COPY config/database.yml.docker config/database.yml
 
 # Compile our assets, moving unneeded directories out of way for the prod image
 # after compilation has completed.
-RUN rails assets:precompile && \
+RUN rails assets:precompile --trace && \
       rm -rf tmp/cache log && \
       mkdir -p /var/cache/app/app && \
-      mv node_modules spec /var/cache/app && \
+      mv node_modules /var/cache/app && \
       mv app/assets /var/cache/app/app && \
       mv app/javascript /var/cache/app/app
 
@@ -44,6 +58,10 @@ COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
 COPY --from=builder /app/ /app/
 COPY --from=builder /var/cache/app/ /app/
 
+COPY lib/ /app/lib
+COPY app/ /app/app
+COPY spec /app/spec
+
 ################################################################################
 FROM base AS prod
 
@@ -54,8 +72,18 @@ ENV RAILS_ENV=production
 RUN bundle install --jobs 4 --retry 5 --without development test && \
       apk rm $BUILD_PACKAGES $DEV_PACKAGES
 
-# Grab the app with all compiled assets and docker configuration from builder
-COPY --from=builder /app/ /app/
+COPY bin/ /app/bin
+COPY .rspec .ruby-version Rakefile /app/
+COPY vendor/ /app/vendor
+COPY config.ru /app/config.ru
+COPY config/ /app/config
+COPY config/database.yml.docker /app/config/database.yml
+COPY public/ /app/public
+COPY db/ /app/db
+COPY lib/ /app/lib
+COPY app/ /app/app
+
+COPY --from=builder public/ /app/public
 
 # Run the server
 EXPOSE 3000