Skip to content

Commit

Permalink
Feature/cde 40 deployment (#24)
Browse files Browse the repository at this point in the history
* CDE-40 chore: Add build demo step

* CDE-40 chore: Update codefresh pipeline

* CDE-40 chore: Update codefresh pipeline

* CDE-40 feat: Replace node script with shell script
  • Loading branch information
afonsobspinto authored Feb 23, 2024
1 parent 4bcf77a commit be2d48b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
ARG PARENT=ubuntu/nginx
ARG NODE_PARENT=node:18.12.1
ARG VITE_API_KEY



FROM ${NODE_PARENT} as build
ENV APP_DIR=/app
ARG VITE_API_KEY
ENV VITE_API_KEY=$VITE_API_KEY
ENV APP_DIR=/app

WORKDIR ${APP_DIR}

Expand All @@ -15,6 +17,9 @@ RUN npm install

# user node
ADD --chown=node:node . ${APP_DIR}
COPY replace_env_vars.sh /usr/local/bin/replace_env_vars.sh
RUN chmod +x /usr/local/bin/replace_env_vars.sh
RUN /usr/local/bin/replace_env_vars.sh
RUN npm run build

FROM ${PARENT}
Expand Down
2 changes: 2 additions & 0 deletions k8s/codefresh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ steps:
tag: "${{CF_SHORT_REVISION}}"
dockerfile: Dockerfile
registry: ${{REGISTRY}}
build_arguments:
- VITE_API_KEY=${{VITE_API_KEY}}
deploy-to-kubernetes:
image: codefresh/cf-deploy-kubernetes
tag: latest
Expand Down
6 changes: 6 additions & 0 deletions replace_env_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
# replace_env_vars.sh

for var in $(printenv | grep VITE_ | awk -F= '{print $1}'); do
sed -i 's|import.meta.env.'$var'|"'$(printenv $var)'"|g' ./demo/*.js
done

0 comments on commit be2d48b

Please sign in to comment.