update migrations
All checks were successful
Build and Publish / build-release (push) Successful in 1m37s
All checks were successful
Build and Publish / build-release (push) Successful in 1m37s
This commit is contained in:
@@ -35,7 +35,7 @@ config :provider_service, ProviderService.EventStore,
|
||||
hostname: "localhost",
|
||||
pool_size: 10
|
||||
|
||||
config :provider_service, :s3_bucket, "policy-bucket"
|
||||
config :provider_service, :s3_bucket, "provider-service"
|
||||
|
||||
config :provider_service,
|
||||
solicitation_service_url: "http://localhost:8081"
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import Config
|
||||
|
||||
# config/runtime.exs is executed for all environments, including
|
||||
# during releases. It is executed after compilation and before the
|
||||
# system starts, so it is typically used to load production configuration
|
||||
# and secrets from environment variables or elsewhere. Do not define
|
||||
# any compile-time configuration in here, as it won't be applied.
|
||||
# The block below contains prod specific runtime configuration.
|
||||
|
||||
logger_level =
|
||||
case System.get_env("LOG_LEVEL", "info") do
|
||||
"debug" -> :debug
|
||||
@@ -29,6 +36,15 @@ config :ex_aws, :s3,
|
||||
|
||||
config :provider_service, :s3_bucket, System.get_env("S3_BUCKET", "provider-service")
|
||||
|
||||
# ## Using releases
|
||||
#
|
||||
# If you use `mix release`, you need to explicitly enable the server
|
||||
# by passing the PHX_SERVER=true when you start it:
|
||||
#
|
||||
# PHX_SERVER=true bin/provider_service start
|
||||
#
|
||||
# Alternatively, you can use `mix phx.gen.release` to generate a `bin/server`
|
||||
# script that automatically sets the env var above.
|
||||
if System.get_env("PHX_SERVER") do
|
||||
config :provider_service, ProviderServiceWeb.Endpoint, server: true
|
||||
end
|
||||
@@ -37,9 +53,6 @@ if cookie = System.get_env("RELEASE_COOKIE") do
|
||||
config :elixir, :cookie, cookie
|
||||
end
|
||||
|
||||
config :provider_service, ProviderServiceWeb.Endpoint,
|
||||
http: [port: String.to_integer(System.get_env("PORT", "8080"))]
|
||||
|
||||
if config_env() == :prod do
|
||||
database_url =
|
||||
System.get_env("DATABASE_URL") ||
|
||||
@@ -52,13 +65,14 @@ if config_env() == :prod do
|
||||
|
||||
config :provider_service, ProviderService.Repo,
|
||||
url: database_url,
|
||||
pool_size: 1,
|
||||
pool_size: String.to_integer(System.get_env("DATABASE_POOL_SIZE") || "1"),
|
||||
socket_options: maybe_ipv6
|
||||
|
||||
config :provider_service, ProviderService.EventStore,
|
||||
serializer: Commanded.Serialization.JsonSerializer,
|
||||
url: database_url,
|
||||
pool_size: 1
|
||||
schema: "eventstore",
|
||||
pool_size: String.to_integer(System.get_env("EVENTSTORE_POOL_SIZE") || "1")
|
||||
|
||||
secret_key_base =
|
||||
System.get_env("SECRET_KEY_BASE") ||
|
||||
@@ -72,9 +86,10 @@ if config_env() == :prod do
|
||||
config :provider_service, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY")
|
||||
|
||||
config :provider_service, ProviderServiceWeb.Endpoint,
|
||||
url: [host: host, port: 80, scheme: "http"],
|
||||
url: [host: host, port: String.to_integer(System.get_env("PORT", "4000")), scheme: "http"],
|
||||
http: [
|
||||
ip: {0, 0, 0, 0, 0, 0, 0, 0}
|
||||
ip: {0, 0, 0, 0, 0, 0, 0, 0},
|
||||
port: String.to_integer(System.get_env("PORT", "4000"))
|
||||
],
|
||||
secret_key_base: secret_key_base
|
||||
end
|
||||
37
lib/provider_service/release.ex
Normal file
37
lib/provider_service/release.ex
Normal file
@@ -0,0 +1,37 @@
|
||||
defmodule ProviderService.Release do
|
||||
@moduledoc """
|
||||
Used for executing DB release tasks when run in production without Mix
|
||||
installed.
|
||||
"""
|
||||
@app :provider_service
|
||||
|
||||
def migrate do
|
||||
load_app()
|
||||
init_event_store()
|
||||
|
||||
for repo <- repos() do
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
|
||||
end
|
||||
end
|
||||
|
||||
def rollback(repo, version) do
|
||||
load_app()
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
|
||||
end
|
||||
|
||||
defp repos do
|
||||
Application.fetch_env!(@app, :ecto_repos)
|
||||
end
|
||||
|
||||
defp load_app do
|
||||
Application.ensure_all_started(:ssl)
|
||||
Application.ensure_all_started(:postgrex)
|
||||
Application.ensure_loaded(@app)
|
||||
end
|
||||
|
||||
def init_event_store do
|
||||
config = ProviderService.EventStore.config()
|
||||
|
||||
:ok = EventStore.Tasks.Init.exec(config, [])
|
||||
end
|
||||
end
|
||||
@@ -3,6 +3,33 @@ controllers:
|
||||
enabled: true
|
||||
type: deployment
|
||||
replicas: 1
|
||||
initContainers:
|
||||
migrate:
|
||||
image:
|
||||
repository: gitea.corredorconect.com/software-engineering/provider-service
|
||||
tag: '{{ $.Chart.AppVersion }}'
|
||||
command:
|
||||
- "/bin/provider_service"
|
||||
args:
|
||||
- "eval"
|
||||
- "ProviderService.Release.migrate"
|
||||
env:
|
||||
MIX_ENV: prod
|
||||
SECRET_KEY_BASE:
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-secrets'
|
||||
key: secretKeyBase
|
||||
RELEASE_COOKIE:
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-secrets'
|
||||
key: cookie
|
||||
DATABASE_URL:
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-cluster-pg-app'
|
||||
key: uri
|
||||
containers:
|
||||
main:
|
||||
image:
|
||||
@@ -43,7 +70,7 @@ controllers:
|
||||
DATABASE_URL:
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: provider-service-cluster-pg-app
|
||||
name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-cluster-pg-app'
|
||||
key: uri
|
||||
probes:
|
||||
liveness:
|
||||
@@ -132,3 +159,18 @@ rawResources:
|
||||
owner: provider_service
|
||||
storage:
|
||||
size: 5Gi
|
||||
|
||||
database:
|
||||
enabled: true
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Database
|
||||
suffix: database
|
||||
spec:
|
||||
spec:
|
||||
name: provider_service
|
||||
owner: provider_service
|
||||
cluster:
|
||||
name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-cluster-pg'
|
||||
schemas:
|
||||
- name: eventstore
|
||||
owner: provider_service
|
||||
|
||||
2
rel/overlays/bin/migrate
Normal file
2
rel/overlays/bin/migrate
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec /opt/app/bin/provider_service eval "ProviderService.Release.migrate"
|
||||
2
rel/overlays/bin/migrate.bat
Normal file
2
rel/overlays/bin/migrate.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
@echo off
|
||||
call bin\provider_service.bat eval "ProviderService.Release.migrate"
|
||||
2
rel/overlays/bin/server
Normal file
2
rel/overlays/bin/server
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec /opt/app/bin/provider_service start
|
||||
2
rel/overlays/bin/server.bat
Normal file
2
rel/overlays/bin/server.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
@echo off
|
||||
call bin\provider_service.bat start
|
||||
Reference in New Issue
Block a user