[Docker] Install gems and js packages into the image

To see the changes persisted into the container run `docker-compose` build
`docker-compose down -v` no longer requires to reinstall gems/packages
It's also possible to have branches with different gemfiles, without having
to install between them constantly
This commit is contained in:
Earlopain 2022-01-05 13:41:41 +01:00
parent 8d2bd155f3
commit 82d7ff59e0
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
4 changed files with 18 additions and 4 deletions

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
# Ignore everything
**
# Allow only the files that are actually needed
!/package.json
!/yarn.lock
!/Gemfile
!/Gemfile.lock

View File

@ -4,10 +4,16 @@ FROM ruby:2.7.3-alpine
RUN apk --no-cache add nodejs yarn postgresql-client ffmpeg vips tzdata \ RUN apk --no-cache add nodejs yarn postgresql-client ffmpeg vips tzdata \
git build-base postgresql-dev glib-dev git build-base postgresql-dev glib-dev
# Nice to have packages # Nice to have packages
RUN apk --no-cache add nano sudo bash 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 # shoreman
RUN wget -O /usr/bin/shoreman https://github.com/chrismytton/shoreman/raw/master/shoreman.sh \ RUN wget -O /usr/bin/shoreman https://github.com/chrismytton/shoreman/raw/master/shoreman.sh \
&& chmod +x /usr/bin/shoreman && chmod +x /usr/bin/shoreman

View File

@ -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.<sup>1</sup> By the time you get back the install will surely have completed.<sup>1</sup>
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. 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.
<sub><sup>1</sup> If the install did not finish by the time an activity is complete please select another activity to avoid crippling boredom.</sub> <sub><sup>1</sup> If the install did not finish by the time an activity is complete please select another activity to avoid crippling boredom.</sub>
#### Development Database #### Development Database

View File

@ -2,14 +2,13 @@ version: "3"
services: services:
e621: e621:
build: ./docker build: ./
volumes: volumes:
- .:/app - .:/app
- node_modules:/app/node_modules - node_modules:/app/node_modules
- public_packs:/app/public/packs - public_packs:/app/public/packs
- public_packs_test:/app/public/packs-test - public_packs_test:/app/public/packs-test
- post_data:/app/public/data - post_data:/app/public/data
- gems:/usr/local/bundle
environment: environment:
DATABASE_URL: postgresql://danbooru:@postgres DATABASE_URL: postgresql://danbooru:@postgres
RAILS_ENV: development RAILS_ENV: development
@ -76,7 +75,6 @@ volumes:
elastic_data: elastic_data:
db_data: db_data:
redis_data: redis_data:
gems:
node_modules: node_modules:
public_packs: public_packs:
public_packs_test: public_packs_test: