Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESCKAN chore: Replace hardcoded URL with env var #35

Merged
merged 8 commits into from
Jul 5, 2024
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
ARG NODE_PARENT=node:18

FROM ${NODE_PARENT} as frontend

ARG VITE_COMPOSER_API_URL
ENV VITE_COMPOSER_API_URL=$VITE_COMPOSER_API_URL
ENV BUILDDIR=/app

WORKDIR ${BUILDDIR}
COPY package.json ${BUILDDIR}
COPY yarn.lock ${BUILDDIR}
COPY nginx/default.conf ${BUILDDIR}
COPY replace_env_vars.sh ${BUILDDIR}

RUN yarn install
COPY . ${BUILDDIR}
RUN /bin/sh replace_env_vars.sh './src/settings.ts'
RUN yarn build


FROM nginx:1.19.3-alpine

RUN cat /etc/nginx/conf.d/default.conf
Expand Down
22 changes: 12 additions & 10 deletions deploy/codefresh/codefresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@ steps:
title: "Building SCKANNER"
type: "build"
image_name: "sckanner"
tag: "${{CF_BUILD_ID}}"
tag: "${{CF_SHORT_REVISION}}"
dockerfile: Dockerfile
working_directory: ./sckan-explorer
buildkit: true
buildkit: true
registry: "${{CODEFRESH_REGISTRY}}"
arguments:
build_arguments:
- VITE_COMPOSER_API_URL=${{VITE_COMPOSER_API_URL}}
deploy:
stage: "deploy"
title: "Deploying SCKANNER"
image: codefresh/kubectl
image: codefresh/cf-deploy-kubernetes
tag: latest
working_directory: ./sckan-explorer/deploy/k8s
commands:
- export CLUSTER_NAME="${{CLUSTER_NAME}}"
- export NAMESPACE="${{NAMESPACE}}"
- export CF_BUILD_ID
- export REGISTRY="${{REGISTRY}}/"
- export DOMAIN="${{DOMAIN}}"
- chmod +x ./deploy.sh
- ./deploy.sh
- /cf-deploy-kubernetes sckanner.yaml
- /cf-deploy-kubernetes ingress.yaml
environment:
- KUBECONTEXT=${{CLUSTER_NAME}}
- KUBERNETES_NAMESPACE=${{NAMESPACE}}
7 changes: 7 additions & 0 deletions replace_env_vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

DEST_FILES=$1

for var in $(printenv | grep VITE_ | awk -F= '{print $1}'); do
sed -i 's|import.meta.env.'$var'|"'$(printenv $var)'"|g' "$DEST_FILES"
done
5 changes: 1 addition & 4 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const SCKAN_ORDER_JSON_URL =
export const SCKAN_MAJOR_NERVES_JSON_URL =
'https://raw.githubusercontent.com/smtifahim/SCKAN-Apps/master/sckan-explorer/json/major-nerves.json';

export const COMPOSER_API_URL = import.meta.env.VITE_COMPOSER_API_URL;
export const SCKAN_DATABASE_SUMMARY_URL_LATEST =
'https://raw.githubusercontent.com/smtifahim/SCKAN-Apps/master/sckan-explorer/json/sckan-stats/sckan-version-2024-03-04/';

Expand All @@ -26,10 +27,6 @@ export const DATABASE_FILES = {
[FILES.CATEGORY]: 'stats-population-category-count.json',
};

// TODO: To change to the env variable when the deployment gets integrated with other sckan projects @dario
export const COMPOSER_API_URL = 'https://composer.scicrunch.io/api';
//export const COMPOSER_API_URL = import.meta.env.VITE_COMPOSER_API_URL

export const OTHER_X_AXIS_ID = 'OTHER_X';
export const OTHER_X_AXIS_LABEL = 'Other';
export const OTHER_PHENOTYPE_LABEL = 'other';
Expand Down