diff --git a/.dockerignore b/.dockerignore index 5a97688..75af1a9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,4 @@ stats data publicDirs devel +.git diff --git a/Dockerfile b/Dockerfile index ab4a483..0d4c940 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,13 @@ WORKDIR /server COPY package.json ./ COPY package-lock.json ./ -RUN npm i +# RUN npm i COPY . . -RUN npm run export +# RUN npm run export -CMD [ "bash", "scripts/make.sh" ] -CMD [ "npm", "run", "start" ] +# CMD [ "bash", "scripts/make.sh" ] +# CMD [ "npm", "run", "start" ] +CMD [ "scripts/start.sh" ] EXPOSE 80 EXPOSE 8080 diff --git a/scripts/make.sh b/scripts/make.sh old mode 100644 new mode 100755 index 06262e3..c30d179 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -34,13 +34,7 @@ makeNextSubmodule() { ln -sf "$PWD/submodules/${1}/out" "$PWD/nextStatic/${2}" } -checkFile "$PWD/src/server.ts" -checkFile "$PWD/package.json" -checkFile "$PWD/package-lock.json" - -git pull -git submodule update --init --recursive - +log 'Making project' log "Installing node modules for server" npm install npm audit fix diff --git a/scripts/runDocker.sh b/scripts/runDocker.sh index ca16d5d..5620c41 100755 --- a/scripts/runDocker.sh +++ b/scripts/runDocker.sh @@ -5,6 +5,7 @@ if [ "$1" == "build" ]; then exit elif [ "$1" == "run" ]; then # --entrypoint bash \ + scripts/setup.sh docker run -it \ -p 8080:80 \ --mount src="$(pwd)/stats",target=/server/stats,type=bind \ diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 0000000..3c9c027 --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +hr() { + printf '\033[0;32m%*s\033[0m\n' "$(tput cols)" '' | tr ' ' '=' +} + +log() { + hr + echo -e "\033[0;32m${@}\033[0m" + hr +} + +checkFile() { + if [ ! -f "$@" ]; then + log "$@ does not exists, exiting" + exit + fi +} + +log 'Updating / Cloning project' + +checkFile "$PWD/src/server.ts" +checkFile "$PWD/package.json" +checkFile "$PWD/package-lock.json" + +git pull +git submodule update --init --recursive +