-
Notifications
You must be signed in to change notification settings - Fork 9
/
.environment
51 lines (46 loc) · 2.28 KB
/
.environment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
export RELATIONSHIPS_JSON="$(echo ${{ .Assets.EnvPrefix }}_RELATIONSHIPS | base64 --decode)"
{{- if .Database }}
# Set database environment variables
export DB_HOST="$(echo $RELATIONSHIPS_JSON | jq -r '.{{ .Database }}[0].host')"
export DB_PORT="$(echo $RELATIONSHIPS_JSON | jq -r '.{{ .Database }}[0].port')"
export DB_DATABASE="$(echo $RELATIONSHIPS_JSON | jq -r '.{{ .Database }}[0].path')"
export DB_USERNAME="$(echo $RELATIONSHIPS_JSON | jq -r '.{{ .Database }}[0].username')"
export DB_PASSWORD="$(echo $RELATIONSHIPS_JSON | jq -r '.{{ .Database }}[0].password')"
{{ if eq .Database "postgresql" }}export DB_CONNECTION="postgresql"{{ else }}export DB_CONNECTION="${{ .DatabaseUpper }}_SCHEME"{{ end }}
export DATABASE_URL="${DB_CONNECTION}://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}"
{{- end -}}
{{- if .Cache }}
# Set Cache environment variables
export CACHE_HOST="$(echo $RELATIONSHIPS_JSON | jq -r '.{{ .Cache }}[0].host')"
export CACHE_PORT="$(echo $RELATIONSHIPS_JSON | jq -r '.{{ .Cache }}[0].port')"
export CACHE_PASSWORD="$(echo $RELATIONSHIPS_JSON | jq -r '.{{ .Cache }}[0].password')"
export CACHE_SCHEME="$(echo $RELATIONSHIPS_JSON | jq -r '.{{ .Cache }}[0].scheme')"
export CACHE_URL="${CACHE_SCHEME}://${CACHE_PASSWORD}@${CACHE_HOST}:${CACHE_PORT}"
{{- end -}}
{{- if or (eq .Cache "redis") (eq .Cache "redis_persistent") }}
# Set Redis environment variables
export REDIS_URL="$CACHE_URL"
{{- end -}}
{{- if eq .Stack.Name "strapi" }}
# Set Strapi-specific environment variables
export DATABASE_HOST="$DB_HOST"
export DATABASE_PORT="$DB_PORT"
export DATABASE_NAME="$DB_PATH"
export DATABASE_USERNAME="$DB_USERNAME"
export DATABASE_PASSWORD="$DB_PASSWORD"
export DATABASE_SCHEME="$DB_CONNECTION"
# Set secrets needed by Strapi, if they are not set
# Prefer setting these as project secret variables with {{ .Assets.Binary }} variable:create env:SECRET_NAME --sensitive=true
if [ -z "$ADMIN_JWT_SECRET" ]; then
export ADMIN_JWT_SECRET="${{ .Assets.EnvPrefix }}_PROJECT_ENTROPY"
fi
if [ -z "$JWT_SECRET" ]; then
export JWT_SECRET="${{ .Assets.EnvPrefix }}_PROJECT_ENTROPY"
fi
if [ -z "$API_TOKEN_SALT" ]; then
export API_TOKEN_SALT="${{ .Assets.EnvPrefix }}_PROJECT_ENTROPY"
fi
if [ -z "$APP_KEYS" ]; then
export APP_KEYS="${{ .Assets.EnvPrefix }}_PROJECT_ENTROPY"
fi
{{- end -}}