Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ FROM ruby:3.2.5
# socat is just for binding ports within docker, not needed for the application
RUN apt-get update && apt-get install -y --force-yes \
libsodium-dev libgmp3-dev libssl-dev \
libpq-dev postgresql-client \
postgresql-common \
nodejs \
socat \
texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra \
;
# NB: Postgres client from Debian is 9.4 - not sure if this is acceptable
;

# pg_dump requires that the client library >= the server (major) version
RUN yes | /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
RUN apt-get install -y --force-yes libpq-dev postgresql-client-17

RUN mkdir /SAPI
WORKDIR /SAPI
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
}

# Fixes error "Cannot render console from 172.22.0.1!" when in Docker
config.web_console.whitelisted_ips = [
config.web_console.allowed_ips = [
'10.0.0.0/8',
'172.16.0.0/12',
'192.168.0.0/16'
Expand Down
12 changes: 12 additions & 0 deletions db/functions/squish_null/20250522113100.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE OR REPLACE FUNCTION public.squish_null(TEXT) RETURNS TEXT
LANGUAGE SQL IMMUTABLE
AS $fn$
SELECT
CASE WHEN public.squish($1) = ''
THEN NULL
ELSE public.squish($1)
END;
$fn$;

COMMENT ON FUNCTION public.squish_null(TEXT) IS
'Squishes whitespace characters in a string and returns null for empty string';
9 changes: 0 additions & 9 deletions db/helpers/000_helpers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ AS $FUNCTION$
);
$FUNCTION$;

CREATE OR REPLACE FUNCTION squish_null(TEXT) RETURNS TEXT
LANGUAGE SQL IMMUTABLE
AS $$
SELECT CASE WHEN SQUISH($1) = '' THEN NULL ELSE SQUISH($1) END;
$$;

COMMENT ON FUNCTION squish_null(TEXT) IS
'Squishes whitespace characters in a string and returns null for empty string';

-- This function previously had a different signature - ensure that the old version is gone
DROP FUNCTION IF EXISTS full_name_with_spp(rank_name VARCHAR(255), full_name VARCHAR(255));

Expand Down
13 changes: 13 additions & 0 deletions db/migrate/20250522113100_update_squish_null_function.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class UpdateSquishNullFunction < ActiveRecord::Migration[7.1]
def up
safety_assured do
execute function_sql('20250522113100', 'squish_null')
end
end

def down
safety_assured do
execute function_sql('20150421071444', 'squish_null')
end
end
end
8 changes: 6 additions & 2 deletions db/structure.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 34 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ services:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin

db:
container_name: sapi-db
db-pg10:
container_name: sapi-db-pg10
image: postgres:10
command: postgres -c max_wal_size=2GB
healthcheck:
Expand All @@ -66,6 +66,27 @@ services:
POSTGRES_HOST_AUTH_METHOD: "trust"
POSTGRES_DB: "sapi_development"

db-pg17:
container_name: sapi-db-pg17
image: postgres:17
command: postgres -c max_wal_size=2GB
healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"]
timeout: 45s
interval: 10s
retries: 10
volumes:
- ./db_init:/docker-entrypoint-initdb.d
- ./db/structure.sql:/docker-entrypoint-initdb.d/sapi_schema.sql
- 'pg17data:/var/lib/postgresql/data'
ports:
- "${SAPI_CONTAINER_DB_PORT:-5417}:5432"
networks:
- sapi
environment:
POSTGRES_HOST_AUTH_METHOD: "trust"
POSTGRES_DB: "sapi_development"

rails:
container_name: sapi-rails
build:
Expand Down Expand Up @@ -114,17 +135,18 @@ services:
tty: true
environment:
MAILER_ADDRESS: sapi-mailcatcher
SAPI_DATABASE_HOST: sapi-db
SAPI_DATABASE_HOST: sapi-db-pg17
SAPI_DATABASE_USERNAME: postgres
SAPI_DATABASE_PORT: 5432
SAPI_SIDEKIQ_REDIS_URL: redis://sapi-redis:6379/0
SAPI_SIDEKIQ_REDIS_CACHE_URL: redis://sapi-redis-cache:6380/0
CAPTIVE_BREEDING_DATABASE_HOST: sapi-db
CAPTIVE_BREEDING_DATABASE_HOST: sapi-db-pg17
SAPI_S3_PORT: '${SAPI_CONTAINER_S3_PORT:-9000}'
depends_on:
- redis
- redis_cache
- db
- db-pg10
- db-pg17
- mailcatcher
- minio
deploy:
Expand All @@ -138,7 +160,7 @@ services:
stdin_open: true
tty: true
environment:
SAPI_DATABASE_HOST: sapi-db
SAPI_DATABASE_HOST: sapi-db-pg17
SAPI_SIDEKIQ_REDIS_URL: redis://sapi-redis:6379/0
# Defaults to blank; used by AppSignal:
USER: "$USER"
Expand Down Expand Up @@ -176,7 +198,8 @@ services:
networks:
- sapi
depends_on:
- db
- db-pg10
- db-pg17
- redis
- redis_cache
- mailcatcher
Expand All @@ -185,14 +208,13 @@ services:
volumes: *rails_volumes
environment:
MAILER_ADDRESS: sapi-mailcatcher
SAPI_DATABASE_HOST: sapi-db
SAPI_DATABASE_HOST: sapi-db-pg17
SAPI_DATABASE_USERNAME: postgres
SAPI_DATABASE_PORT: 5432
SAPI_SIDEKIQ_REDIS_URL: redis://sapi-redis:6379/0
SAPI_S3_PORT: '${SAPI_CONTAINER_S3_PORT:-9000}'
SAPI_SIDEKIQ_REDIS_URL: redis://sapi-redis:6379/0
SAPI_SIDEKIQ_REDIS_CACHE_URL: redis://sapi-redis-cache:6380/0
CAPTIVE_BREEDING_DATABASE_HOST: sapi-db

CAPTIVE_BREEDING_DATABASE_HOST: sapi-db-pg17
mailcatcher:
container_name: sapi-mailcatcher
image: sj26/mailcatcher
Expand All @@ -203,6 +225,7 @@ services:

volumes:
pgdata:
pg17data:
bundler_gems:
redis_data:
minio-data:
Expand Down
Loading