Skip to content

Commit 9ed2c2b

Browse files
committed
postgre test was misnamed; rename and recapture results
1 parent 75e9d58 commit 9ed2c2b

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

test/results/postgresql/Dockerfile

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,44 @@
22
# check=error=true
33

44
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
5-
# docker build -t test_postgresql .
6-
# docker run -d -p 80:80 -e RAILS_MASTER_KEY=<value from config/master.key> --name test_postgresql test_postgresql
5+
# docker build -t demo .
6+
# docker run -d -p 80:80 -e RAILS_MASTER_KEY=<value from config/master.key> --name demo demo
77

88
# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html
99

1010
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
1111
ARG RUBY_VERSION=xxx
12-
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
12+
FROM ruby:$RUBY_VERSION-slim AS base
1313

1414
# Rails app lives here
1515
WORKDIR /rails
1616

17+
# Update gems and bundler
18+
RUN gem update --system --no-document && \
19+
gem install -N bundler
20+
1721
# Install base packages
1822
RUN apt-get update -qq && \
19-
apt-get install --no-install-recommends -y curl libjemalloc2 libvips postgresql-client && \
23+
apt-get install --no-install-recommends -y curl libjemalloc2 postgresql-client && \
2024
rm -rf /var/lib/apt/lists /var/cache/apt/archives
2125

2226
# Set production environment
23-
ENV RAILS_ENV="production" \
24-
BUNDLE_DEPLOYMENT="1" \
27+
ENV BUNDLE_DEPLOYMENT="1" \
2528
BUNDLE_PATH="/usr/local/bundle" \
26-
BUNDLE_WITHOUT="development"
29+
BUNDLE_WITHOUT="development:test" \
30+
RAILS_ENV="production"
31+
2732

2833
# Throw-away build stage to reduce size of final image
2934
FROM base AS build
3035

3136
# Install packages needed to build gems
3237
RUN apt-get update -qq && \
33-
apt-get install --no-install-recommends -y build-essential git libpq-dev libyaml-dev pkg-config && \
38+
apt-get install --no-install-recommends -y build-essential libpq-dev libyaml-dev && \
3439
rm -rf /var/lib/apt/lists /var/cache/apt/archives
3540

3641
# Install application gems
37-
COPY Gemfile Gemfile.lock vendor ./
38-
42+
COPY Gemfile Gemfile.lock ./
3943
RUN bundle install && \
4044
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
4145
bundle exec bootsnap precompile --gemfile
@@ -50,20 +54,21 @@ RUN bundle exec bootsnap precompile app/ lib/
5054
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
5155

5256

53-
54-
5557
# Final stage for app image
5658
FROM base
5759

60+
5861
# Copy built artifacts: gems, application
5962
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
6063
COPY --from=build /rails /rails
6164

6265
# Run and own only the runtime files as a non-root user for security
63-
RUN groupadd --system --gid 1000 rails && \
64-
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
66+
ARG UID=xxx \
67+
GID=1000
68+
RUN groupadd -f -g $GID rails && \
69+
useradd -u $UID -g $GID rails --create-home --shell /bin/bash && \
6570
chown -R rails:rails db log storage tmp
66-
USER 1000:1000
71+
USER rails:rails
6772

6873
# Entrypoint prepares the database.
6974
ENTRYPOINT ["/rails/bin/docker-entrypoint"]

test/results/postgresql/database.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ test:
7575
# production:
7676
# url: <%= ENV["MY_APP_DATABASE_URL"] %>
7777
#
78+
# Connection URLs for non-primary databases can also be configured using
79+
# environment variables. The variable name is formed by concatenating the
80+
# connection name with `_DATABASE_URL`. For example:
81+
#
82+
# CACHE_DATABASE_URL="postgres://cacheuser:cachepass@localhost/cachedatabase"
83+
#
7884
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
7985
# for a full overview on how database connection configuration can be specified.
8086
#

test/results/postgresql/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
environment:
1616
- DATABASE_URL=postgres://root:password@postgres-db/
1717
secrets:
18-
- source: master_key
18+
- source: RAILS_MASTER_KEY
1919
target: /rails/config/master.key
2020
depends_on:
2121
postgres-db:
@@ -35,5 +35,5 @@ services:
3535
retries: 30
3636

3737
secrets:
38-
master_key:
39-
file: ./config/master.key
38+
RAILS_MASTER_KEY
39+
file: ./config/master.key

0 commit comments

Comments
 (0)