Skip to content

Commit

Permalink
[ACA-4715] provide support for Docker variables (#3329)
Browse files Browse the repository at this point in the history
* provide support for Docker variables

* remove test code

* update docs
  • Loading branch information
DenysVuika authored Jul 12, 2023
1 parent 5abbda7 commit 1532d65
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN apk update && apk upgrade
USER 101

COPY docker/default.conf.template /etc/nginx/templates/
COPY docker/docker-entrypoint.d/* /docker-entrypoint.d/

COPY dist/content-ce /usr/share/nginx/html/
COPY dist/content-ce/app.config.json /etc/nginx/templates/app.config.json.template
Expand Down
112 changes: 112 additions & 0 deletions docker/docker-entrypoint.d/30-sed-on-appconfig.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/sh

set -e

APP_CONFIG_FILE="${NGINX_ENVSUBST_OUTPUT_DIR}/app.config.json"

if [ -n "${APP_CONFIG_AUTH_TYPE}" ]; then
echo "SET APP_CONFIG_AUTH_TYPE"

sed -e "s/\"authType\": \".*\"/\"authType\": \"${APP_CONFIG_AUTH_TYPE}\"/g" \
-i "$APP_CONFIG_FILE"
fi

if [ -n "${APP_CONFIG_PROVIDER}" ]; then
echo "SET APP_CONFIG_PROVIDER"

sed -e "s/\"providers\": \".*\"/\"providers\": \"${APP_CONFIG_PROVIDER}\"/g" \
-i "$APP_CONFIG_FILE"
fi

if [ -n "${APP_CONFIG_IDENTITY_HOST}" ]; then
echo "SET APP_CONFIG_IDENTITY_HOST"

replace="\/"
encodedIdentity=${APP_CONFIG_IDENTITY_HOST//\//$replace}
sed -e "s/\"identityHost\": \".*\"/\"identityHost\": \"$encodedIdentity\"/g" \
-i "$APP_CONFIG_FILE"
fi

if [ -n "${APP_CONFIG_OAUTH2_HOST}" ]; then
echo "SET APP_CONFIG_OAUTH2_HOST"

replace="\/"
encoded=${APP_CONFIG_OAUTH2_HOST//\//$replace}
sed -e "s/\"host\": \".*\"/\"host\": \"${encoded}\"/g" \
-i "$APP_CONFIG_FILE"
fi

if [ -n "${APP_CONFIG_OAUTH2_CLIENTID}" ]; then
echo "SET APP_CONFIG_OAUTH2_CLIENTID"

sed -e "s/\"clientId\": \".*\"/\"clientId\": \"${APP_CONFIG_OAUTH2_CLIENTID}\"/g" \
-i "$APP_CONFIG_FILE"
fi

if [ -n "${APP_CONFIG_OAUTH2_IMPLICIT_FLOW}" ]; then
echo "SET APP_CONFIG_OAUTH2_IMPLICIT_FLOW"

sed -e "s/\"implicitFlow\": [^,]*/\"implicitFlow\": ${APP_CONFIG_OAUTH2_IMPLICIT_FLOW}/g" \
-i "$APP_CONFIG_FILE"
fi

if [ -n "${APP_CONFIG_OAUTH2_SILENT_LOGIN}" ]; then
echo "SET APP_CONFIG_OAUTH2_SILENT_LOGIN"

sed -e "s/\"silentLogin\": [^,]*/\"silentLogin\": ${APP_CONFIG_OAUTH2_SILENT_LOGIN}/g" \
-i "$APP_CONFIG_FILE"
fi

if [ -n "${APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI}" ]; then
echo "SET APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI"

replace="\/"
encoded=${APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI//\//$replace}
sed -e "s/\"redirectSilentIframeUri\": \".*\"/\"redirectSilentIframeUri\": \"${encoded}\"/g" \
-i "$APP_CONFIG_FILE"
fi

if [ -n "${APP_CONFIG_OAUTH2_REDIRECT_LOGIN}" ]; then
echo "SET APP_CONFIG_OAUTH2_REDIRECT_LOGIN"

replace="\/"
encoded=${APP_CONFIG_OAUTH2_REDIRECT_LOGIN//\//$replace}
sed -e "s/\"redirectUri\": \".*\"/\"redirectUri\": \"${encoded}\"/g" \
-i "$APP_CONFIG_FILE"
fi

if [ -n "${APP_CONFIG_OAUTH2_REDIRECT_LOGOUT}" ]; then
echo "SET APP_CONFIG_OAUTH2_REDIRECT_LOGOUT"

replace="\/"
encoded=${APP_CONFIG_OAUTH2_REDIRECT_LOGOUT//\//$replace}
sed -e "s/\"redirectUriLogout\": \".*\"/\"redirectUriLogout\": \"${encoded}\"/g" \
-i "$APP_CONFIG_FILE"
fi

if [[ -n "${APP_CONFIG_BPM_HOST}" ]]; then
echo "SET APP_CONFIG_BPM_HOST"

replace="\/"
encoded=${APP_CONFIG_BPM_HOST//\//$replace}
sed -e "s/\"bpmHost\": \".*\"/\"bpmHost\": \"${encoded}\"/g" \
-i "$APP_CONFIG_FILE"
fi

if [[ -n "${APP_CONFIG_ECM_HOST}" ]]; then
echo "SET APP_CONFIG_ECM_HOST"

replace="\/"
encoded=${APP_CONFIG_ECM_HOST//\//$replace}
sed -e "s/\"ecmHost\": \".*\"/\"ecmHost\": \"${encoded}\"/g" \
-i "$APP_CONFIG_FILE"
fi

if [ -n "${APP_BASE_SHARE_URL}" ]; then
echo "SET APP_BASE_SHARE_URL"

replace="\/"
encoded=${APP_BASE_SHARE_URL//\//$replace}
sed -e "s/\"baseShareUrl\": \".*\"/\"baseShareUrl\": \"${encoded}\"/g" \
-i "$APP_CONFIG_FILE"
fi
5 changes: 4 additions & 1 deletion docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ docker rmi -f $DOCKER_IMAGE_REPO
docker build -t $DOCKER_IMAGE_REPO .

echo "http://localhost:${HOST_PORT}"
docker run --rm -it --user 1000:1000 --publish $HOST_PORT:$CONTAINER_PORT $DOCKER_IMAGE_REPO

docker run --rm -it \
--user 1000:1000 \
--publish $HOST_PORT:$CONTAINER_PORT $DOCKER_IMAGE_REPO
32 changes: 32 additions & 0 deletions docs/getting-started/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,35 @@ docker run --rm -it --user 1000:1000 --publish 8081:8080 alfresco/alfresco-conte
```

Navigate to `http://localhost:8081`.

## Docker Variables

There is a number of environment variables that you can define to override the default configuration:

**Example**

```shell
docker run --rm -it \
--env APP_CONFIG_AUTH_TYPE="OAUTH" \
--env APP_CONFIG_ECM_HOST="https://some.host.com" \
--user 1000:1000 \
--publish 8081:8080 alfresco/alfresco-content-app
```

### Configuration Mapping

| Name | Config Path |
|----------------------------------------------|----------------------------------|
| APP_CONFIG_AUTH_TYPE | `authType` |
| APP_CONFIG_PROVIDER | `providers` |
| APP_CONFIG_IDENTITY_HOST | `identityHost` |
| APP_CONFIG_BPM_HOST | `bpmHost` |
| APP_CONFIG_ECM_HOST | `ecmHost` |
| APP_BASE_SHARE_URL | `baseShareUrl` |
| APP_CONFIG_OAUTH2_HOST | `oauth2.host` |
| APP_CONFIG_OAUTH2_CLIENTID | `oauth2.clientId` |
| APP_CONFIG_OAUTH2_IMPLICIT_FLOW | `oauth2.implicitFlow` |
| APP_CONFIG_OAUTH2_SILENT_LOGIN | `oauth2.silentLogin` |
| APP_CONFIG_OAUTH2_REDIRECT_SILENT_IFRAME_URI | `oauth2.redirectSilentIframeUri` |
| APP_CONFIG_OAUTH2_REDIRECT_LOGIN | `oauth2.redirectUri` |
| APP_CONFIG_OAUTH2_REDIRECT_LOGOUT | `oauth2.redirectUriLogout` |

0 comments on commit 1532d65

Please sign in to comment.