Skip to content

Commit ffdb40e

Browse files
Moves precompile into entrypoint.sh to avoid caching
1 parent e2e6cc7 commit ffdb40e

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ RUN node -v
1616

1717
RUN apt-get update -qq && apt-get install -y build-essential nodejs yarn
1818

19+
RUN apt install libmagickwand-dev
20+
RUN apt install imagemagick
21+
1922
# Copy the Gemfile as well as the Gemfile.lock and install
2023
# the RubyGems. This is a separate step so the dependencies
2124
# will be cached unless changes to one of those two files
@@ -30,15 +33,15 @@ RUN yarn install --check-files
3033
# Copy the main application.
3134
COPY . ./
3235

33-
# Precompile Rails assets
34-
RUN RAILS_ENV=production bundle exec rake assets:clean
35-
RUN RAILS_ENV=production bundle exec rake assets:precompile
36-
3736
# Expose port 3000 to the Docker host, so we can access it
3837
# from the outside.
3938
EXPOSE 3000:3000
4039

4140
# The main command to run when the container starts. Also
4241
# tell the Rails dev server to bind to all interfaces by
4342
# default.
44-
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
43+
# CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
44+
45+
RUN chmod 777 ./entrypoint.sh
46+
RUN chmod +x ./entrypoint.sh
47+
ENTRYPOINT [ "bash", "-c", "./entrypoint.sh" ]

deploy.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ execute_ssh "docker-compose down"
2929
# Pull the latest code from the git repo
3030
execute_ssh "source ~/.start_ssh && git fetch origin && git reset --hard origin/master && git pull origin master"
3131

32+
# Fix permissions
33+
execute_ssh "chmod 777 ./entrypoint.sh"
34+
3235
# Build using docker-compose
3336
execute_ssh "docker-compose build"
3437

entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
# Precompile Rails assets
4+
rm /app/tmp/pids/server.pid
5+
RAILS_ENV=production bundle exec rake assets:clean
6+
RAILS_ENV=production bundle exec rake assets:precompile
7+
# Run server
8+
RAILS_ENV=production bundle exec rails server -b 0.0.0.0
9+

0 commit comments

Comments
 (0)