diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..0e4f06c81153f4df5bc8fce7a4643fc3e43cfe28 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git +node_modules +dist diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..efa26b192283f0316db086dbb650ab0bbaf45b0d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM node:lts-alpine AS base + +LABEL maintainer="David Trattnig <david.trattnig@subsquare.at>" + +# Base Stage + +WORKDIR /aura +COPY package*.json ./ +RUN npm install + +# Development Stage + +FROM base AS dev +EXPOSE 5000 +CMD ["./run.sh", "dev"] + +# Production Stage + +FROM base AS prod +COPY . . +CMD ["./run.sh", "build"] \ No newline at end of file diff --git a/run.sh b/run.sh index 4f2ab6165351a71bafb4907b288c3c320d6bdaa4..6f38920e3e1319e60c539f9f81a73c32c950f2e9 100755 --- a/run.sh +++ b/run.sh @@ -11,7 +11,7 @@ docker="false" # - build # -if [[ $* =~ ^(dev|build)$ ]]; then +if [[ $* =~ ^(dev|build|push)$ ]]; then mode=$1 fi @@ -42,14 +42,38 @@ if [[ $docker == "false" ]]; then npm run build fi - fi # +++ DOCKER COMMANDS +++ # if [[ $docker == "true" ]]; then - BASE_D=$(realpath "${BASH_SOURCE%/*}/") + BASE_DIR=$(readlink -f .) + echo "Absolute base dir: " $BASE_DIR + + ### Start local development server ### + + if [[ $mode == "dev" ]]; then + #TODO docker run command for dev server (See dev stage in Dockerfile) + echo "Missing implementation" + fi + + ### Create build for use in production ### + + if [[ $mode == "prod" ]]; then + #TODO docker run command for prod build (See prod stage in Dockerfile) + echo "Missing implementation" + fi + + ### Create Docker Image from local project ### - # ~~~ 404 ~~~ + if [[ $mode == "build" ]]; then + docker build -t autoradio/engine-clock . + fi + + ### Pushes the latest Docker Image to Docker Hub ### + + if [[ $mode == "push" ]]; then + docker push autoradio/engine-clock + fi fi \ No newline at end of file