-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[examples/dockerdev] Add .dockerignore #26
Comments
You don't need |
But you do need # for all code you usually don't want .git history in image, just the current commit you have checked out
.git
# you usually don't want dockerfile and compose files in the image either (to not lost caches on not significant changes)
*Dockerfile*
*docker-compose*
.dockerignore
# Local gems (there should be separate `bundle install` step in Dockerfile)
vendor/bundle/
# Specs or tests (may contain large fixtures)
spec/
# Keys for Rails credentials (they should be mounted into container from outside)
config/master.key
config/credentials/*.key
# CI configuration
.circleci/
.github/
# Backend dev tools
.rspec_status
.rubocop*
.bundle/
# running application artifacts
log/
tmp/
public/system/
public/storage/
public/uploads/
# Frontend
public/packs*
node_modules/
# Developer-specific things. So bad that there is no global .dockerignore. See https://github.com/moby/moby/issues/12843
/.idea/
# What else to exclude?
# - Helm chart or Ansible playbooks or anything deployment-specific, not used in production |
@Envek I disagree. I know it sounds weird, but since all those folders are inside of build context - all of them are being sent to the docker engine, and it might take a long time. Note that I do not copy or add anything, my Dockerfile for development is equal to yours - it only sets up the environment. I thought that I had some issues with docker and it just stuck. But no, I just had to wait like 3 minutes for all the context files, before the build even started. Then I've added a This is because on my project there's a large (I found that solution here: docker/compose#4396 (comment)) |
Ah, yes, you're right! Build context! Another solution is to limit build context at docker-compose level (see Compose file v2 --- a/examples/dockerdev/docker-compose.yml
+++ b/examples/dockerdev/docker-compose.yml
@@ -2,8 +2,8 @@ version: '2.4'
x-app: &app
build:
- context: .
- dockerfile: ./.dockerdev/Dockerfile
+ context: .dockerdev
+ dockerfile: Dockerfile
args:
RUBY_VERSION: '2.6.3'
PG_MAJOR: '11' But that also requires changing --- a/examples/dockerdev/.dockerdev/Dockerfile
+++ b/examples/dockerdev/.dockerdev/Dockerfile
@@ -31,7 +31,7 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo 'deb http://dl.yarnpkg.com/debian/ stable main' > /etc/apt/sources.list.d/yarn.list
# Install dependencies
-COPY .dockerdev/Aptfile /tmp/Aptfile
+COPY Aptfile /tmp/Aptfile
RUN apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get -yq dist-upgrade && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends \
libpq-dev \ |
As usually there is |
Yup, so I believe one of those solutions is worth to be added to your awesome post! 😄 |
Also changed the “Ruby on Whales” post accordingly. |
The changes to the |
Guys, I'm loving your post, but it could be even better for newbies (like me) if it also included
.dockerignore
file, which is important to make an image-building much faster for bigger projects.The text was updated successfully, but these errors were encountered: