Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add working example for setting up local prod docker image. #302

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ To view staging logs go to https://grafana-nomad.lib.princeton.edu and log in wi

Build Docker Image: `docker build . -t dpul-collections`

Set up database: `mix setup`

The SECRET_KEY_BASE below is just a filler one for the purpose of testing locally.

Run Docker Image: `docker run -t -p 4000:4000 -e DATABASE_URL='ecto://postgres:@host.docker.internal:5434/database' -e SECRET_KEY_BASE='B8rwzeX3DFLveiJ4cP28lRGc0PWdEr8ZF/hDoPRucw95Nzf2IPnu7lhEB+Yldx6Z' dpul-collections`
Run Docker Image: `docker run -t -p 4000:4000 -e INDEXER=true -e INDEX_CACHE_COLLECTIONS='cache_version:1,write_collection:dpulc' -e PHX_HOST=localhost:4000 -e SOLR_CONFIG_SET='dpul-collections' -e SOLR_USERNAME='solr' -e SOLR_PASSWORD='SolrRocks' -e SOLR_READ_COLLECTION='dpulc' -e SOLR_BASE_URL='http://host.docker.internal:8985' -e RELEASE_IP=127.0.0.1 -e FIGGY_DATABASE_URL='ecto://postgres:[email protected]:5435/postgres' -e DATABASE_URL='ecto://postgres:@host.docker.internal:5434/dpul_collections_dev' -e SECRET_KEY_BASE='B8rwzeX3DFLveiJ4cP28lRGc0PWdEr8ZF/hDoPRucw95Nzf2IPnu7lhEB+Yldx6Z' dpul-collections`

Commit Solr: `curl http://solr:SolrRocks@localhost:8985/solr/dpulc/update?commit=true`

Available at http://localhost:4000
6 changes: 3 additions & 3 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ if config_env() == :prod do
base_url: solr_base_url,
read_collection: solr_read_collection,
config_set: solr_config_set,
username: "",
password: ""
username: System.get_env("SOLR_USERNAME") || "",
password: System.get_env("SOLR_PASSWORD") || ""
}

index_cache_collections =
Expand Down Expand Up @@ -116,7 +116,7 @@ if config_env() == :prod do

host = System.get_env("PHX_HOST") || "example.com"
port = String.to_integer(System.get_env("PORT") || "4000")
check_origin = ["https://#{host}"]
check_origin = ["//#{host}"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this could just be true woudl that be more straightforward? See https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#socket/3-common-configuration

and looking at the host in prod:

iex([email protected])1> DpulCollectionsWeb.Endpoint.config(:url)[:host]
"dpul-collections-staging.lib.princeton.edu"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me!


config :dpul_collections, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")

Expand Down