diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2492720 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM node:14 + +WORKDIR /tmp +COPY . . + +RUN ["./build_script.sh"] + +FROM node:14 + +WORKDIR /usr/src/app +COPY --from=0 /tmp/build . + +RUN npm install + +EXPOSE 8080 + +CMD [ "node", "server/index.js" ] \ No newline at end of file diff --git a/build_script.sh b/build_script.sh new file mode 100644 index 0000000..1d55e09 --- /dev/null +++ b/build_script.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# create folder to pack all +echo "Starting build process..." +mkdir build + +# build janken tool and move +cd tools/janken +echo "Starting janken tool build..." +npm install +npm run build +cd ../../ +mv tools/janken/tool build +echo "Finished janken tool build..." + +# build client and move +cd main-web/client +echo "Starting client build..." +npm install +npm run build +cd ../../ +mv main-web/client/client build/client +echo "Finished client build..." + +# build admin and move +cd main-web/admin +echo "Starting admin ui build..." +npm install +npm run build +cd ../../ +mv main-web/admin/build build/admin +echo "Finished admin ui build..." + +# build server and move +cd main-web/server +echo "Starting server build..." +npm install +npm run build +cd ../../ +cd build/ +echo "Starting retrieval of db credentials..." +export catherine_db_endpoint=$(aws --region=ap-northeast-1 ssm get-parameter --name "db-endpoint" --with-decryption --output text --query Parameter.Value) +export catherine_db_user=$(aws --region=ap-northeast-1 ssm get-parameter --name "db-username" --with-decryption --output text --query Parameter.Value) +export catherine_db_pass=$(aws --region=ap-northeast-1 ssm get-parameter --name "db-password" --with-decryption --output text --query Parameter.Value) +echo "Saving db credentials to .env file..." +cat > .env <