Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 3 additions & 4 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ USER theia
COPY --chown=theia bashrc /home/theia/.bashrc
COPY --chown=theia profile /home/theia/.profile
COPY --chown=theia create_kubeconfig.sh /home/theia/create_kubeconfig.sh
COPY --chown=theia entrypoint.sh /home/theia/entrypoint.sh
RUN chmod +x /home/theia/entrypoint.sh

RUN cd /home/theia && \
curl -fsSLO https://github.com/kubernetes-sigs/krew/releases/latest/download/krew-linux_amd64.tar.gz && \
Expand All @@ -161,8 +163,5 @@ RUN cd /home/theia && \

WORKDIR /home/theia/applications/browser

# Launch the backend application via node
ENTRYPOINT [ "node", "/home/theia/applications/browser/lib/backend/main.js" ]

# Arguments passed to the application
ENTRYPOINT [ "/home/theia/entrypoint.sh" ]
CMD [ "/home/project", "--hostname=0.0.0.0" ]
11 changes: 7 additions & 4 deletions build/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ alias k=kubectl
complete -o default -F __start_kubectl k
complete -C /usr/bin/terraform terraform

export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
export KREW_ROOT=/home/theia/.krew
export PATH="$KREW_ROOT/bin:$PATH"

if [ ! -f "~/.kube/config" ]; then
if [ ! -f "$HOME/.kube/config" ]; then
kubectl config set-cluster local --server="https://kubernetes.default" --certificate-authority "/run/secrets/kubernetes.io/serviceaccount/ca.crt"
kubectl config set-credentials local --token="$(cat /run/secrets/kubernetes.io/serviceaccount/token)"
kubectl config set-context local --cluster "local" --user "local"
kubectl config set-context local --namespace="$USER"
kubectl config set-context local --namespace="${KUBECONFIG_NAMESPACE:-$USER}"

/home/theia/create_kubeconfig.sh
if [ -n "$CLUSTER_K8S_API_HOST" ]; then
/home/theia/create_kubeconfig.sh
fi
fi

clear && figlet -w 120 welcome @ acend
26 changes: 17 additions & 9 deletions build/create_kubeconfig.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
#!/bin/bash

TOKEN=$(cat /run/secrets/kubernetes.io/serviceaccount/token)
NAMESPACE=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
SA_NAMESPACE=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
CA=$(cat /run/secrets/kubernetes.io/serviceaccount/ca.crt | base64 -w0)

cat << EOF > kubeconfig.yaml
KUBECONFIG_PATH="${KUBECONFIG_PATH:-${KUBECONFIG:-kubeconfig.yaml}}"
KUBECONFIG_NAMESPACE="${KUBECONFIG_NAMESPACE:-$SA_NAMESPACE}"
KUBECONFIG_CLUSTER_NAME="${KUBECONFIG_CLUSTER_NAME:-acend-training-cluster}"
KUBECONFIG_CONTEXT="${KUBECONFIG_CONTEXT:-acend-training}"
KUBECONFIG_USERNAME="${KUBECONFIG_USERNAME:-acend-user}"

mkdir -p "$(dirname "$KUBECONFIG_PATH")"

cat << EOF > "$KUBECONFIG_PATH"
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ${CA}
server: https://${CLUSTER_K8S_API_HOST}:6443
name: acend-training-cluster
name: ${KUBECONFIG_CLUSTER_NAME}
contexts:
- context:
cluster: acend-training-cluster
namespace: ${NAMESPACE}
user: acend-user
name: acend-training
current-context: acend-training
cluster: ${KUBECONFIG_CLUSTER_NAME}
namespace: ${KUBECONFIG_NAMESPACE}
user: ${KUBECONFIG_USERNAME}
name: ${KUBECONFIG_CONTEXT}
current-context: ${KUBECONFIG_CONTEXT}
kind: Config
preferences: {}
users:
- name: acend-user
- name: ${KUBECONFIG_USERNAME}
user:
token: ${TOKEN}
EOF
9 changes: 9 additions & 0 deletions build/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# On OpenShift, HOME is overridden to /home/project (the PVC mount).
# Copy profile files from the image so the terminal gets the correct
# prompt, aliases, and PATH on first run. Existing files are not overwritten,
# so user customisations on the PVC are preserved.
[ -f "$HOME/.bashrc" ] || cp /home/theia/.bashrc "$HOME/.bashrc"
[ -f "$HOME/.profile" ] || cp /home/theia/.profile "$HOME/.profile"

exec node /home/theia/applications/browser/lib/backend/main.js "$@"
Loading