Skip to content

Commit

Permalink
ci(build): read oidc client from argo env
Browse files Browse the repository at this point in the history
  • Loading branch information
velrest committed Dec 16, 2021
1 parent 5c139ff commit 7572148
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
13 changes: 11 additions & 2 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ARG AUTH_ROLE_CUSTOMER
ARG TIMED_STAGING_HOST
ARG TIMED_PROD_HOST
ARG OIDC_HOST
ARG OIDC_CLIENT
# Install dependencies.
RUN apk update && \
apk add --no-cache \
Expand All @@ -32,6 +31,16 @@ FROM nginx:1.18-alpine AS server

# Copy the built application to the new image.
COPY --from=builder /tmp/project/dist /usr/share/nginx/html

# Copy the NGINX configuration with proper location handling.
COPY nginx.conf /etc/nginx/conf.d/default.conf


WORKDIR /usr/share/nginx/html

COPY ./docker-entrypoint.sh /
ENV OIDC_CLIENT cc

EXPOSE 80

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
2 changes: 1 addition & 1 deletion frontend/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module.exports = function (environment) {
"OIDC_HOST",
"http://timed.local/auth/realms/timed/protocol/openid-connect"
);
ENV["ember-simple-auth-oidc"].clientId = env("OIDC_CLIENT", "timed-public");
ENV["ember-simple-auth-oidc"].clientId = "sso-client-id";
}

return ENV;
Expand Down
23 changes: 23 additions & 0 deletions frontend/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env sh

set -eu

urlencode() {
# urlencode <string>
# blatantly pinched from https://gist.github.com/cdown/1163649

local length="${#1}"
for i in $(seq 0 $((length-1))); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
}

sed -i \
-e "s/sso-client-id/$(urlencode ${OIDC_CLIENT})/g" \
/var/www/html/index.html

exec "$@"

0 comments on commit 7572148

Please sign in to comment.