From 4a5eb2d4309122ce1ce6dac7a9f4e9eaefbcef46 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Fri, 7 Oct 2022 13:36:29 +0200 Subject: [PATCH] fix: release tests --- docker-compose.dev.yml | 3 --- docker-compose.rc.yml | 2 -- docker-compose.yml | 2 -- package.json | 3 ++- packages/system-api/src/core/config/TipiConfig.ts | 2 +- scripts/common.sh | 3 ++- scripts/deploy/release-rc.sh | 3 +++ scripts/start-dev.sh | 2 +- scripts/start.sh | 8 +++----- scripts/watcher.sh | 2 +- 10 files changed, 13 insertions(+), 17 deletions(-) create mode 100755 scripts/deploy/release-rc.sh diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 5ffbbacd..5dc6b1cc 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -51,13 +51,10 @@ services: ports: - 3001:3001 volumes: - ## Docker sock - - /var/run/docker.sock:/var/run/docker.sock:ro - ${PWD}/apps:/runtipi/apps:ro - ${PWD}/repos:/runtipi/repos:ro - ${PWD}/state:/runtipi/state - ${PWD}/packages/system-api/src:/api/src - - ${PWD}/logs:/app/logs - ${STORAGE_PATH}:/app/storage - ${PWD}/.env.dev:/runtipi/.env # - /api/node_modules diff --git a/docker-compose.rc.yml b/docker-compose.rc.yml index f22045b1..697edad1 100644 --- a/docker-compose.rc.yml +++ b/docker-compose.rc.yml @@ -44,8 +44,6 @@ services: tipi-db: condition: service_healthy volumes: - ## Docker sock - - /var/run/docker.sock:/var/run/docker.sock:ro - ${PWD}/apps:/runtipi/apps:ro - ${PWD}/repos:/runtipi/repos:ro - ${PWD}/state:/runtipi/state diff --git a/docker-compose.yml b/docker-compose.yml index 05b72833..c8267d5d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,8 +44,6 @@ services: tipi-db: condition: service_healthy volumes: - ## Docker sock - - /var/run/docker.sock:/var/run/docker.sock:ro - ${PWD}/apps:/runtipi/apps:ro - ${PWD}/repos:/runtipi/repos:ro - ${PWD}/state:/runtipi/state diff --git a/package.json b/package.json index 3f7e40f2..aeb09206 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "start:rc": "docker-compose -f docker-compose.rc.yml --env-file .env up --build", "start:prod": "docker-compose --env-file .env up --build", "start:pg": "docker run --name test-db -p 5433:5432 -d --rm -e POSTGRES_PASSWORD=postgres postgres", - "version": "echo $npm_package_version" + "version": "echo $npm_package_version", + "release:rc": "./scripts/deploy/release-rc.sh" }, "devDependencies": { "@commitlint/cli": "^17.0.3", diff --git a/packages/system-api/src/core/config/TipiConfig.ts b/packages/system-api/src/core/config/TipiConfig.ts index de08c2f0..6ad213f0 100644 --- a/packages/system-api/src/core/config/TipiConfig.ts +++ b/packages/system-api/src/core/config/TipiConfig.ts @@ -9,7 +9,7 @@ if (process.env.NODE_ENV !== 'production') { dotenv.config({ path: '.env' }); } const { - LOGS_FOLDER = 'logs', + LOGS_FOLDER = '/app/logs', LOGS_APP = 'app.log', LOGS_ERROR = 'error.log', NODE_ENV = 'development', diff --git a/scripts/common.sh b/scripts/common.sh index d89938da..98ad3942 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -68,7 +68,8 @@ function clean_logs() { } function kill_watcher() { - watcher_pid=$(pgrep -f "runtipi/state/events") + watcher_pid="$(ps aux | grep "scripts/watcher" | grep -v grep | awk '{print $2}')" + # kill it if it's running if [[ -n $watcher_pid ]]; then # If multiline kill each pid diff --git a/scripts/deploy/release-rc.sh b/scripts/deploy/release-rc.sh new file mode 100755 index 00000000..9af9d918 --- /dev/null +++ b/scripts/deploy/release-rc.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t meienberger/runtipi:rc-"$(npm run version --silent)" . --push diff --git a/scripts/start-dev.sh b/scripts/start-dev.sh index 29b99e11..852cf526 100755 --- a/scripts/start-dev.sh +++ b/scripts/start-dev.sh @@ -4,8 +4,8 @@ source "${BASH_SOURCE%/*}/common.sh" ROOT_FOLDER="${PWD}" kill_watcher -"${ROOT_FOLDER}/scripts/watcher.sh" & chmod -R a+rwx "${ROOT_FOLDER}/state/events" chmod -R a+rwx "${ROOT_FOLDER}/state/system-info.json" +"${ROOT_FOLDER}/scripts/watcher.sh" & docker compose -f docker-compose.dev.yml --env-file "${ROOT_FOLDER}/.env.dev" up --build diff --git a/scripts/start.sh b/scripts/start.sh index ad5410bc..16a08eca 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -100,10 +100,11 @@ if [[ "${NGINX_PORT}" != "80" ]] && [[ "${DOMAIN}" != "tipi.localhost" ]]; then exit 1 fi +kill_watcher # Configure Tipi "${ROOT_FOLDER}/scripts/configure.sh" - -kill_watcher +chmod -R a+rwx "${ROOT_FOLDER}/state/events" +chmod -R a+rwx "${ROOT_FOLDER}/state/system-info.json" "${ROOT_FOLDER}/scripts/watcher.sh" & # Copy the config sample if it isn't here @@ -201,9 +202,6 @@ mv -f "$ENV_FILE" "$ROOT_FOLDER/.env" # Run system-info.sh echo "Running system-info.sh..." bash "${ROOT_FOLDER}/scripts/system-info.sh" -echo "Fixing permissions for events file" -chmod -R a+rwx "${ROOT_FOLDER}/state/events" -chmod -R a+rwx "${ROOT_FOLDER}/state/system-info.json" ## Don't run if config-only if [[ ! $ci == "true" ]]; then diff --git a/scripts/watcher.sh b/scripts/watcher.sh index 6226d6be..e4d7de40 100755 --- a/scripts/watcher.sh +++ b/scripts/watcher.sh @@ -17,7 +17,7 @@ function set_status() { write_log "Setting status for ${id} to ${status}" # Update the status of the event - sed -i '' "s/${id} [a-z]*/${id} ${status}/g" "${WATCH_FILE}" + sed -i "s/${id}.*$/$(echo "${id} ${status}" | sed 's/\//\\\//g')/" "$WATCH_FILE" } function run_command() {