Skip to content

Commit

Permalink
Correct Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
TomNaessens committed Jun 8, 2024
1 parent 5dda46d commit dbadae2
Showing 1 changed file with 10 additions and 59 deletions.
69 changes: 10 additions & 59 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,67 +1,18 @@
##################
### Base image ###
##################
FROM ruby:3.0.2-alpine as base
FROM ruby:3.3.2

# Install the required packages for building
# Delete APK cache at the end (for smaller production images)
RUN apk update && \
apk add --virtual build-dependencies build-base && \
apk add shared-mime-info mariadb-dev sqlite-dev nodejs tzdata imagemagick && \
rm -rf /var/cache/apk/*
ENV RAILS_ENV=production

# Create a working directory
WORKDIR /tap
RUN apt update && apt install -y nodejs cron

# Copy the gemfile to the working directory
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
WORKDIR /app

# Install dependencies
# Use BuildKit cache for caching dependencies
RUN --mount=type=cache,target=vendor/cache bundle install
COPY ./Gemfile ./Gemfile.lock /app/

# Copy all of the .gem files needed to run the application into the vendor/cache directory.
# In the future, when running [bundle install(1)][bundle-install], use the gems in the cache in preference to the ones on rubygems.org
RUN bundle cache
RUN gem install bundler
RUN bundle install

########################
### Production image ###
########################
FROM base as production
COPY . /app

# Copy the sourcecode
COPY . .
RUN bundle exec rails assets:precompile

# Run rails in production mode
ENV RAILS_ENV production

# Expose port 80
# This is the main port for the application
EXPOSE 80

# Pre-compile assets
RUN rake assets:precompile

# Docker Entrypoint
# Will be started when the container is started
ENTRYPOINT sh docker-start.sh

#########################
### Development image ###
#########################
FROM base as development

# Copy the sourcecode
COPY . .

# Run rails in production mode
ENV RAILS_ENV development

# Expose port 80
# This is the main port for the application
EXPOSE 80

# Docker Entrypoint
# Will be started when the container is started
CMD sh docker-start.sh
CMD bundle exec rails s -b 0.0.0.0

0 comments on commit dbadae2

Please sign in to comment.