diff --git a/bin/script/build b/bin/script/build deleted file mode 100755 index 0cf812a..0000000 --- a/bin/script/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -$SCRIPT_DIR/exec build \ No newline at end of file diff --git a/bin/script/down b/bin/script/down deleted file mode 100755 index 7b6b977..0000000 --- a/bin/script/down +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -$SCRIPT_DIR/exec down \ No newline at end of file diff --git a/bin/script/exec b/bin/script/exec deleted file mode 100755 index 87c1e00..0000000 --- a/bin/script/exec +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -COMMAND="$@" -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) - -#LOAD ENV VARIABLES FROM .ENV -#export $(grep -v '^#' "${SCRIPT_DIR}/../../.env" | xargs) - -#MAC -if [[ "$OSTYPE" == "darwin"* ]]; then - docker compose -f "${SCRIPT_DIR}/../../docker/docker-compose-mac.yml" $COMMAND - -#LINUX -elif [[ "$OSTYPE" == "linux-gnu" ]]; then - docker compose -f "${SCRIPT_DIR}/../../docker/docker-compose.yml" $COMMAND - -else - echo "Dieses Skript wird auf deinem Gerät nicht unterstützt" - exit 1 -fi - -#UNSET ENV VARIABLES FROM .ENV -#unset $(grep -v '^#' "${SCRIPT_DIR}/../../.env" | sed -E 's/(.*)=.*/\1/' | xargs) diff --git a/bin/script/firstRun b/bin/script/firstRun new file mode 100755 index 0000000..2ddc1b5 --- /dev/null +++ b/bin/script/firstRun @@ -0,0 +1,18 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +PROJECT_DIR=$(realpath $SCRIPT_DIR/../../) +ENV_DIR=$(realpath $PROJECT_DIR/../../../) + +source $ENV_DIR/bin/messages +source $ENV_DIR/bin/drun + +# Install node Packages +infomsg "[frontend]: NPM install" +drun frontend npm install +successmsg "[frontend]: NPM install done" + +# Initial build of website +infomsg "[frontend]: NPM run build" +drun frontend npm run build +successmsg "[frontend]: NPM run build done" diff --git a/bin/script/init b/bin/script/init index 24a6c31..3b030bf 100755 --- a/bin/script/init +++ b/bin/script/init @@ -2,18 +2,13 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) PROJECT_DIR=$(realpath $SCRIPT_DIR/../../) -ENV_DIR=$(realpath $PROJECT_DIR/../../) +ENV_DIR=$(realpath $PROJECT_DIR/../../../) -# Build and start docker containers -$SCRIPT_DIR/exec build -$SCRIPT_DIR/exec up -d +source $ENV_DIR/bin/messages -# Source drun -source $ENV_DIR/bin/script/drun - -# Install node Packages -drun mytube-frontend npm install -drun mytube-frontend npm install -g @angular/cli - -# Initial build of website -drun mytube-frontend npm run build \ No newline at end of file +# Check docker-compose.yml file +if [ ! -f "$PROJECT_DIR/docker/docker-compose.yml" ] ; then + infomsg "[frontend] Creating docker-compose.yml" + cp "$PROJECT_DIR/docker/docker-compose.yml.dist" "$PROJECT_DIR/docker/docker-compose.yml" + successmsg "[frontend] Created docker-compose.yml" +fi \ No newline at end of file diff --git a/bin/script/stop b/bin/script/stop deleted file mode 100755 index 64393e9..0000000 --- a/bin/script/stop +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -$SCRIPT_DIR/exec stop \ No newline at end of file diff --git a/bin/script/up b/bin/script/up deleted file mode 100755 index 7bd3164..0000000 --- a/bin/script/up +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -$SCRIPT_DIR/exec up -d \ No newline at end of file diff --git a/bin/script/update b/bin/script/update new file mode 100755 index 0000000..36e0486 --- /dev/null +++ b/bin/script/update @@ -0,0 +1,29 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +PROJECT_DIR=$(realpath $SCRIPT_DIR/../../) +ENV_DIR=$(realpath $PROJECT_DIR/../../../) +CWD=$(pwd) + +source $ENV_DIR/bin/messages +source $ENV_DIR/bin/drun + + +# Pull branch in project directory +infomsg "[frontend]: Git pull" +cd "$PROJECT_DIR" +git pull +successmsg "[frontend]: Git pull done" + +# Install node Packages +infomsg "[frontend]: NPM install" +drun frontend npm install +successmsg "[frontend]: NPM install done" + +# Initial build of website +infomsg "[frontend]: NPM run build" +drun frontend npm run build +successmsg "[frontend]: NPM run build done" + +# Switch back to current working directory +cd "$CWD" \ No newline at end of file diff --git a/docker/docker-compose-mac.yml b/docker/docker-compose-mac.yml deleted file mode 100644 index 706d8b3..0000000 --- a/docker/docker-compose-mac.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: '3' - -networks: - mytube: - external: true - -services: - mytube-frontend-app: - image: mytube-frontend-app - networks: - - mytube - volumes: - - /Users/flo/dev/frontend/mytube/:/var/www/ - build: - context: ./../ - dockerfile: ./docker/npm/dockerfile - tty: true - - mytube-frontend-nginx: - image: mytube-frontend-nginx - networks: - - mytube - volumes: - - /Users/flo/dev/frontend/mytube/:/var/www/html:z - build: - context: ./../ - dockerfile: ./docker/nginx/dockerfile - ports: - - 80:80 - depends_on: - - mytube-frontend-app \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 030fe98..27a95a7 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3' - networks: mytube: external: true @@ -25,7 +23,9 @@ services: build: context: ./../ dockerfile: ./docker/nginx/dockerfile - ports: - - 80:80 + labels: + - "traefik.http.routers.frontend.rule=Host(`mytube.srv`) || Host(`192.168.152.60`)" + - "traefik.http.routers.frontend.entrypoints=websecure" + - "traefik.http.routers.frontend.tls.certresolver=le" depends_on: - mytube-frontend-app \ No newline at end of file