diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..6910dc010 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +# Ignore everything +** + +# Allow only the files that are actually needed +!/package.json +!/yarn.lock +!/Gemfile +!/Gemfile.lock diff --git a/docker/Dockerfile b/Dockerfile similarity index 76% rename from docker/Dockerfile rename to Dockerfile index 5e8999497..3c6853751 100644 --- a/docker/Dockerfile +++ b/Dockerfile @@ -4,10 +4,16 @@ FROM ruby:2.7.3-alpine RUN apk --no-cache add nodejs yarn postgresql-client ffmpeg vips tzdata \ git build-base postgresql-dev glib-dev - # Nice to have packages RUN apk --no-cache add nano sudo bash +# Install js packages and gems +COPY package.json yarn.lock ./ +RUN yarn install + +COPY Gemfile Gemfile.lock ./ +RUN bundle install + # shoreman RUN wget -O /usr/bin/shoreman https://github.com/chrismytton/shoreman/raw/master/shoreman.sh \ && chmod +x /usr/bin/shoreman diff --git a/README.md b/README.md index 863fc4723..e64ae94a1 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ To mitigate this you can install a WSL distribution and clone the project inside By the time you get back the install will surely have completed.1 6. To confirm the installation worked, open the web browser of your choice and enter `http://localhost:3000` into the address bar and see if the website loads correctly. +Note: When gems or js packages were updated you need to execute `docker-compose build` to reflect them in the container. + 1 If the install did not finish by the time an activity is complete please select another activity to avoid crippling boredom. #### Development Database diff --git a/docker-compose.yml b/docker-compose.yml index 215d2fbd1..675192b01 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,14 +2,13 @@ version: "3" services: e621: - build: ./docker + build: ./ volumes: - .:/app - node_modules:/app/node_modules - public_packs:/app/public/packs - public_packs_test:/app/public/packs-test - post_data:/app/public/data - - gems:/usr/local/bundle environment: DATABASE_URL: postgresql://danbooru:@postgres RAILS_ENV: development @@ -76,7 +75,6 @@ volumes: elastic_data: db_data: redis_data: - gems: node_modules: public_packs: public_packs_test: