-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe6e637
commit 4d1cf21
Showing
8 changed files
with
142 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# syntax = docker/dockerfile:1 | ||
|
||
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile | ||
ARG RUBY_VERSION=3.3.0 | ||
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base | ||
|
||
# Rails app lives here | ||
WORKDIR /rails | ||
|
||
# Set production environment | ||
ENV RAILS_ENV="production" \ | ||
BUNDLE_DEPLOYMENT="1" \ | ||
BUNDLE_PATH="/usr/local/bundle" \ | ||
BUNDLE_WITHOUT="development" \ | ||
WEB_CONCURRENCY="2" \ | ||
RAILS_MAX_THREADS="5" | ||
|
||
# Throw-away build stage to reduce size of final image | ||
FROM base as build | ||
|
||
# Install packages needed to build gems | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y build-essential git libvips pkg-config | ||
|
||
# Copy application code | ||
COPY . . | ||
|
||
# Install application gems | ||
RUN bundle install && \ | ||
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git | ||
|
||
# Rails app lives here | ||
WORKDIR /rails/demo | ||
|
||
# Install application gems | ||
RUN bundle install && \ | ||
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git | ||
|
||
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY | ||
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile | ||
|
||
|
||
# Final stage for app image | ||
FROM base | ||
|
||
# Install packages needed for deployment | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y curl libsqlite3-0 libvips && \ | ||
rm -rf /var/lib/apt/lists /var/cache/apt/archives | ||
|
||
# Copy built artifacts: gems, application | ||
COPY --from=build /usr/local/bundle /usr/local/bundle | ||
COPY --from=build /rails /rails | ||
|
||
WORKDIR /rails/demo | ||
|
||
# Run and own only the runtime files as a non-root user for security | ||
RUN useradd rails --create-home --shell /bin/bash && \ | ||
chown -R rails:rails db log tmp | ||
USER rails:rails | ||
|
||
RUN pwd | ||
|
||
# Entrypoint prepares the database. | ||
ENTRYPOINT ["./bin/docker-entrypoint"] | ||
|
||
# Start the server by default, this can be overwritten at runtime | ||
EXPOSE 3000 | ||
CMD ["./bin/rails", "server"] |
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
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
service: polaris_view_components | ||
image: kirillplatonov/polaris_view_components | ||
|
||
registry: | ||
username: kirillplatonov | ||
password: | ||
- KAMAL_REGISTRY_PASSWORD | ||
|
||
env: | ||
secret: | ||
- RAILS_MASTER_KEY | ||
|
||
servers: | ||
web: | ||
hosts: | ||
- 195.201.128.126 | ||
labels: | ||
traefik.http.routers.polaris_view_components.entrypoints: websecure | ||
traefik.http.routers.polaris_view_components.rule: "Host(`polarisviewcomponents.org`) || Host(`www.polarisviewcomponents.org`)" | ||
traefik.http.routers.polaris_view_components.tls.certresolver: letsencrypt | ||
|
||
traefik: | ||
options: | ||
publish: | ||
- "443:443" | ||
volume: | ||
- "/letsencrypt/acme.json:/letsencrypt/acme.json" | ||
args: | ||
entryPoints.web.address: ":80" | ||
entryPoints.websecure.address: ":443" | ||
entryPoints.web.http.redirections.entryPoint.to: websecure # We want to force https | ||
entryPoints.web.http.redirections.entryPoint.scheme: https | ||
entryPoints.web.http.redirections.entrypoint.permanent: true | ||
certificatesResolvers.letsencrypt.acme.email: "[email protected]" | ||
certificatesResolvers.letsencrypt.acme.storage: "/letsencrypt/acme.json" # Must match the path in `volume` | ||
certificatesResolvers.letsencrypt.acme.httpchallenge: true | ||
certificatesResolvers.letsencrypt.acme.httpchallenge.entrypoint: web |
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,8 @@ | ||
#!/bin/bash -e | ||
|
||
# If running the rails server then create or migrate existing database | ||
if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then | ||
./bin/rails db:prepare | ||
fi | ||
|
||
exec "${@}" |
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 was deleted.
Oops, something went wrong.