Skip to content

Commit

Permalink
LIBFCREPO-1471. Added "dotenv" gem and ".env" files
Browse files Browse the repository at this point in the history
Added the "dotenv" gem to the "Gemfile" (the "dotenv-rails" gem is no
longer needed -- we can use "dotenv" directly).

Added "env_example" and ".env.development" files from the legacy
Archelon.

Modified the ".gitignore" file as in legacy Archelon to enable the
".env.development" file to be included in Git.

Rails 7.1 uses the “foreman” gem to run the asset pipeline watchers and
the Rails server, via the “bin/dev” script. As described in
<ddollar/foreman#702>, “foreman” and the
“dotenv” gem conflict when reading in the environment variables (any
environment variables in the CLI environment are ignored, instead of
overriding the variables in the various “.env” files).

Used the workaround of adding `--env=/dev/null` to the “foreman” command
in the “bin/dev” script so that the CLI environment variables and
“.env” files will work as expected (i.e., that the CLI environment
variables take precedence over the “.env” files).

https://umd-dit.atlassian.net/browse/LIBFCREPO-1471
  • Loading branch information
dsteelma-umd committed Jul 10, 2024
1 parent 279ac73 commit 0f2051d
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 4 deletions.
70 changes: 70 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Entries in this file OVERRIDE entries in the ".env" file.
#
# This file is provides default values for non-workstation-specific,
# non-secret environment variables for use in a development environment
# consisting of Archelon running in a Docker container
# and Plastron on a local workstation.
#
# Workstation-specific or private/secret environment variable settings should
# be made in the ".env" file (which is generated from the "env_example" template
# file).

# --- config/blacklight.yml
SOLR_URL=http://solr-fedora4:8983/solr/fedora4

# --- config/environments/*.rb
FCREPO_BASE_URL=http://fcrepo-local:8080/fcrepo/rest

# --- config/environments/*.rb
# base URL of the IIIF server (which serves the manifests, images, and viewer)
IIIF_BASE_URL=https://iiiflocal/

# --- config/environments/*.rb
# version of the Mirador Static Viewer
MIRADOR_STATIC_VERSION=1.3.0

# Base URL for retrieving files via download urls.
# This should include the entire URL except for the token
RETRIEVE_BASE_URL=http://archelon-local:3000/retrieve/

# The base URL (including a trailing slash) for the handle proxy server
# associated with this application.
# For example: "https://hdl-test.lib.umd.edu/"
HANDLE_HTTP_PROXY_BASE=http://hdl-local/

# --- config/ldap.yml
LDAP_HOST=directory.umd.edu
LDAP_PORT=636
LDAP_BIND_DN=uid=libr-fedora,cn=auth,ou=ldap,dc=umd,dc=edu

# --- config/stomp.yml
# STOMP_HOST=localhost
STOMP_HOST=activemq
STOMP_PORT=61613

# Used by the STOMP listener to generate the URL of the Archelon web application
# for triggering updates to import/export job status
# Should be the root URL of the Archelon Rails application. For example, for
# local development: http://archelon-local:3000/
ARCHELON_URL=http://archelon-local:3000/

# --- config/audit_database.yml
AUDIT_DATABASE_NAME=fcrepo_audit
AUDIT_DATABASE_HOST=localhost
AUDIT_DATABASE_PORT=5433
AUDIT_DATABASE_USERNAME=archelon
AUDIT_DATABASE_PASSWORD=archelon

# basic development mode defaults to SQLite
# this should be overridden in a .env.local
# if a PostgreSQL database is desired
# --- config/database.yml
ARCHELON_DATABASE_ADAPTER=sqlite3
ARCHELON_DATABASE_NAME=db/development.sqlite3
ARCHELON_DATABASE_POOL=5

# --- config/imports.yml
IMPORT_BINARIES_BASE_LOCATION=zip:../../archelon/imports

# --- config/initializers/plastron.rb
PLASTRON_REST_BASE_URL=http://docker.for.mac.localhost:5000/
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
# Ignore bundler config.
/.bundle

# Ignore all environment files (except templates).
/.env*
!/.env*.erb
# UMD Customization
# Ignore environment specific files
.env
.env.local
# End UMD Customization

# Ignore all logfiles and tempfiles.
/log/*
Expand Down
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ gem "bootsnap", require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

# UMD Customization
# Blacklight gem
gem 'blacklight', "~> 8.3.0"

# RSolr Gem
gem 'rsolr'

# dotenv - For storing production configuration parameters
gem 'dotenv', "~> 3.1.2"
# End UMD Customization


group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri windows ]
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ GEM
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
dotenv (3.1.2)
drb (2.2.1)
erubi (1.13.0)
faraday (2.10.0)
Expand Down Expand Up @@ -277,6 +278,7 @@ DEPENDENCIES
capybara
cssbundling-rails
debug
dotenv (~> 3.1.2)
jsbundling-rails
propshaft
puma (>= 5.0)
Expand Down
2 changes: 1 addition & 1 deletion bin/dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ fi
# Default to port 3000 if not specified
export PORT="${PORT:-3000}"

exec foreman start -f Procfile.dev "$@"
exec foreman start -f Procfile.dev --env=/dev/null "$@"
128 changes: 128 additions & 0 deletions env_example
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Example .env file
# Make a copy of this file named ".env" and fill out the properties
# Note: The .env file should _not_ be checked in to Git!

# File containing server-specific Rails environment variables.
# Do not check into Git!

# --- config/blacklight.yml
SOLR_URL=http://localhost:8983/solr/fedora4

# --- config/fcrepo.rb
FCREPO_BASE_URL=http://localhost:8080/rest
# JWT auth token with user "archelon" and role "fedoraAdmin"
FCREPO_AUTH_TOKEN=

# --- config/iiif.rb
# base URL of the IIIF server (which serves the manifests, images, and viewer)
IIIF_BASE_URL=https://iiiflocal/
# version of the Mirador Static Viewer
MIRADOR_STATIC_VERSION = '1.3.0'

# Base URL for retrieving files via download urls.
# This should include the entire URL except for the token
RETRIEVE_BASE_URL=http://archelon-local:3000/retrieve/

# The base URL (including a trailing slash) for the handle proxy server
# associated with this application.
# For example: "https://hdl-test.lib.umd.edu/"
HANDLE_HTTP_PROXY_BASE=

# --- config/ldap.yml
# LDAP Authentication Credentials
LDAP_HOST=
LDAP_PORT=
LDAP_BIND_DN=
LDAP_BIND_PASSWORD=

# fcrepo_audit database connection
AUDIT_DATABASE_NAME=fcrepo_audit
AUDIT_DATABASE_HOST=localhost
AUDIT_DATABASE_PORT=5432
AUDIT_DATABASE_USERNAME=archelon
AUDIT_DATABASE_PASSWORD=archelon

# ActiveMQ/Stomp protocol configuration
# This is used to send export jobs and receive notifications
# when an export job is complete
# -- config/stomp.yml
STOMP_HOST=
STOMP_PORT=

# Used by the STOMP listener to generate the URL of the Archelon web application
# for triggering updates to import/export job status
# Should be the root URL of the Archelon Rails application. For example, for
# local development: http://archelon-local:3000/
ARCHELON_URL=

# --- config/database.yml
# (Production only - not needed for local development)
# The type of database
ARCHELON_DATABASE_ADAPTER=postgresql

# The name of the database
ARCHELON_DATABASE_NAME=archelon

# The encoding to use
ARCHELON_DATABASE_ENCODING=utf8

# The username used to connect to the database
ARCHELON_DATABASE_USERNAME=archelon

# The password used to connect to the database
ARCHELON_DATABASE_PASSWORD=

# The host for the database
ARCHELON_DATABASE_HOST=

# The port for the database
ARCHELON_DATABASE_PORT=5432

# Pool size
ARCHELON_DATABASE_POOL=10

# --- config/ssl.yml
# Used when retrieving export packages from fcrepo.
# These should point to an SSL client cert that has:
# - read permissions to the /exports container
FCREPO_CLIENT_CERT=
FCREPO_CLIENT_KEY=

# --- config/vocabularies.yml
# Base URI for the controlled vocabulary terms
VOCAB_LOCAL_AUTHORITY_BASE_URI=http://vocab.lib.umd.edu/

# The maximum allowed binaries export download size, in bytes
MAX_ALLOWED_BINARIES_DOWNLOAD_SIZE=53687091200

# --- config/application.rb
# Set this if you need to change the default logging level of "info"
# RAILS_LOG_LEVEL=debug

# Production environment variables
# The following environment variables are typically only set when using
# the application in a "production" environment

# --- config/environments/*.rb
# Serve static files only if this env var is defined
# RAILS_SERVE_STATIC_FILES=true

# --- config/secrets.yml
# SECRET_KEY_BASE=

# --- config/imports.yml
# IMPORT_BINARIES_DIR=/data/imports
# IMPORT_BINARIES_BASE_LOCATION=zip+sftp://plastron@archelondev.lib.umd.edu/imports

# -- config/exports.yml
# EXPORT_DIR=/data/exports
# EXPORT_BASE_DESTINATION=sftp://plastron@archelondev.lib.umd.edu/exports


# --- config/initializers/plastron.rb
# Base URL of the Plastron REST endpoint
PLASTRON_REST_BASE_URL=http://localhost:5000/

# Public key from Plastron server for SFTP transfers
# Optional for local development, required for production
PLASTRON_PUBLIC_KEY=

0 comments on commit 0f2051d

Please sign in to comment.