Last active
March 12, 2023 02:35
-
-
Save yosukesan/851dfbe2dbb05ade1fd285f6019f5665 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# make typescript env in docker and run main.ts | |
# | |
if [ $# != 1 ]; then | |
echo "usage: docker_tsc \${file}.ts" | |
exit 1 | |
fi | |
TMP_DOCKERFILE_PATH=./Dockerfile | |
function generate_dockerfile (){ | |
echo -e "FROM node:19-alpine\n\ | |
RUN npm install -g typescript" > ${TMP_DOCKERFILE_PATH} | |
} | |
generate_dockerfile | |
IMAGE=yosukesan:ts_19alpine | |
TS_FILE_PATH=$1 | |
docker build -t ${IMAGE} . | |
docker run --rm --network bridge --volume $(pwd):/tmp ${IMAGE} tsc /tmp/${TS_FILE_PATH} && node ${TS_FILE_PATH%.ts}.js | |
rm -f ${TMP_DOCKERFILE_PATH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment