Skip to content

Commit

Permalink
chore: added logic for capturing env
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-cardenas-coding committed Mar 24, 2024
1 parent 5f91b1f commit c3b5cac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.Caddy
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ COPY --from=modules --chown=appuser:appuser /app/scripts/service-ip.sh /app/serv

RUN apk update && apk upgrade && apk add --no-cache curl ca-certificates bash jq && \
mkdir -p /var/log/caddy/ && chown -R appuser:appuser /var/log/caddy/ && \
chmod -R 700 /var/log/caddy/
chmod -R 700 /var/log/caddy/ && touch /app/.env && chown appuser:appuser /app/.env

USER appuser
EXPOSE 8080 3000
CMD ["/bin/bash", "-c", "/app/service-ip.sh && REACT_APP_API_URI=$API_URI REACT_APP_API_VERSION=$API_VERSION npx react-inject-env set && \
CMD ["/bin/bash", "-c", "/app/service-ip.sh && source /app/.env && REACT_APP_API_URI=$API_URI REACT_APP_API_VERSION=$API_VERSION npx react-inject-env set && \
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile"]
11 changes: 8 additions & 3 deletions deployment/k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ spec:
selector:
matchLabels:
app: api
replicas: 2
replicas: 1
template:
metadata:
labels:
Expand Down Expand Up @@ -175,13 +175,13 @@ spec:
httpGet:
path: /api/v1/health
port: 3000
initialDelaySeconds: 10
initialDelaySeconds: 20
periodSeconds: 3
readinessProbe:
httpGet:
path: /api/v1/health
port: 3000
initialDelaySeconds: 5
initialDelaySeconds: 15
periodSeconds: 3
---
apiVersion: v1
Expand Down Expand Up @@ -214,6 +214,11 @@ spec:
app: ui
spec:
serviceAccountName: hello-universe-role
initContainers:
- name: init-container
image: busybox
command:
["/bin/sh", "-c", "echo 'sleeping for 30 seconds' && sleep 30"]
containers:
- name: ui
image: ghcr.io/spectrocloud/hello-universe:1.1.0-proxy
Expand Down
4 changes: 3 additions & 1 deletion scripts/service-ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ HELLO_UNIVERSE_SERVICE=$(curl --silent --cacert ${CACERT} --header "Authorizatio

# Set API_URI only if QUERY_K8S_API is not empty
echo "Setting API_URI to ${HELLO_UNIVERSE_SERVICE}:3000"
export API_URI=$HELLO_UNIVERSE_SERVICE:$PORT
export API_URI=$HELLO_UNIVERSE_SERVICE:3000
echo "export API_URI=${HELLO_UNIVERSE_SERVICE}:3000" > /app/.env



echo "Hello Universe service IP: ${HELLO_UNIVERSE_SERVICE}:3000"
Expand Down

0 comments on commit c3b5cac

Please sign in to comment.