-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy using Dockerfile instead of buildpack
Based on https://github.com/rails/rails/blob/4f0f3448cde85ff3d1485366231650258ea62b71/railties/lib/rails/generators/rails/app/templates/Dockerfile.tt Deploy failing after heroku/heroku-buildpack-ruby#1428
- Loading branch information
Showing
6 changed files
with
88 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version | ||
ARG RUBY_VERSION=3.2.3 | ||
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base | ||
|
||
# The app lives here | ||
WORKDIR /app | ||
|
||
# Install base packages | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y \ | ||
curl | ||
|
||
# Set production environment | ||
ENV BUNDLE_DEPLOYMENT="1" \ | ||
BUNDLE_PATH="/usr/local/bundle" \ | ||
BUNDLE_WITHOUT="development" | ||
|
||
# Throw-away build stage to reduce size of final image | ||
FROM base as build | ||
|
||
# Install build packages | ||
RUN apt-get install --no-install-recommends -y \ | ||
build-essential \ | ||
git \ | ||
pkg-config | ||
|
||
# Install application gems | ||
COPY Gemfile Gemfile.lock .ruby-version ./ | ||
RUN bundle install | ||
|
||
# Copy application code | ||
COPY . . | ||
|
||
# Final stage for app image | ||
FROM base | ||
|
||
ARG APPUSER=app | ||
ARG APPDIR=/app | ||
|
||
# Clean up installation packages to reduce image size | ||
RUN rm -rf /var/lib/apt/lists /var/cache/apt/archives | ||
|
||
# Copy built artifacts: gems, application | ||
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}" | ||
COPY --from=build $APPDIR $APPDIR | ||
|
||
# Run and own only the runtime files as a non-root user for security | ||
RUN mkdir -p log tmp | ||
RUN groupadd --system --gid 1000 $APPUSER | ||
RUN useradd $APPUSER --uid 1000 --gid 1000 --create-home --shell /bin/bash | ||
RUN chown -R $APPUSER:$APPUSER log tmp | ||
USER 1000:1000 | ||
|
||
RUN gem install overman | ||
|
||
# Start the server by default, this can be overwritten at runtime | ||
CMD ["overman", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
TAG=${TAG:-urls} | ||
PORT=${PORT:-8080} | ||
|
||
# echo commands | ||
set -x | ||
|
||
docker build . -t $TAG | ||
docker run --rm -it --publish ${PORT}:${PORT} --env PORT=${PORT} $TAG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
app = "urls" | ||
|
||
[build] | ||
builder = "heroku/buildpacks:20" | ||
|
||
[env] | ||
PORT = "8080" | ||
RACK_ENV = "production" | ||
|