Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Commit

Permalink
[Windows] Changes to allow docker building on windows (#180)
Browse files Browse the repository at this point in the history
* Changes to allow building on windows, migrated docker build to a node script

* Readme in script, removed extra deps
  • Loading branch information
avdaredevil authored and k8s-ci-robot committed Dec 6, 2019
1 parent c091c8e commit c5d7384
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/Dockerfile
Expand Up @@ -7,7 +7,7 @@ WORKDIR /frontend

COPY . .

RUN npm install && \
RUN npm install && npm rebuild node-sass && \
npm run postinstall && \
CI=true npm run test:coverage && \
npm run build
Expand Down
32 changes: 32 additions & 0 deletions frontend/docker_build.js
@@ -0,0 +1,32 @@
/**
* Docker build cross platform script for KF Metadata
* This will calculate your current hash, and build date and use them
* to build the docker image in the format:
*
* gcr.io/kubeflow-images-public/metadata-frontend:${COMMIT_HASH}
*/
const {exec, spawn} = require('child_process')
const runCmd = cmd => new Promise((res, rej) => exec(cmd, (e, out, err) => e?rej(e):res({out, err})))

// COMMIT_HASH=`git rev-parse HEAD`; docker build -t gcr.io/kubeflow-images-public/metadata-frontend:${COMMIT_HASH} --build-arg COMMIT_HASH=${COMMIT_HASH} --build-arg DATE=\"`date -u`\" .
const main = async _ => {
const commitHash = (await runCmd('git rev-parse HEAD')).out.trim()
const date = new Date().toUTCString()
const protocProcess = spawn(
'docker', [
`build`,
`-t`,`gcr.io/kubeflow-images-public/metadata-frontend:${commitHash}`,
`--build-arg`,`COMMIT_HASH=${commitHash}`,
`--build-arg`,`DATE="${date}"`,
`.`
], {shell: true}
);
protocProcess.stdout.on('data', buffer => console.log(buffer.toString()))
protocProcess.stderr.on('data', buffer => console.error(buffer.toString()))
protocProcess.on('close', code => {
if (code) return
console.log(`Docker image built!`)
})
}

main()
2 changes: 1 addition & 1 deletion frontend/package.json
Expand Up @@ -43,7 +43,7 @@
"apis:metadata": "node ./gen_grpc_web_protos.js",
"apis:service": "java -jar swagger-codegen-cli.jar generate -i ../api/service.swagger.json -l typescript-fetch -o ./src/apis/service -c ./swagger-config.json",
"build": "cross-env EXTEND_ESLINT=true react-scripts build",
"docker": "cross-env COMMIT_HASH=`git rev-parse HEAD`; docker build -t gcr.io/kubeflow-images-public/metadata-frontend:${COMMIT_HASH} --build-arg COMMIT_HASH=${COMMIT_HASH} --build-arg DATE=\"`date -u`\" .",
"docker": "node ./docker_build.js",
"eject": "cross-env EXTEND_ESLINT=true react-scripts eject",
"postinstall": "cd ./server && npm i",
"start": "cross-env EXTEND_ESLINT=true react-scripts start",
Expand Down

0 comments on commit c5d7384

Please sign in to comment.