From b2a5f070f7d2d15bd356bebb84fe65a08a110ebf Mon Sep 17 00:00:00 2001 From: Khvatov Dmitry Date: Wed, 12 Jul 2023 20:39:51 +0200 Subject: [PATCH 1/7] app.1gency.ee --- client/src/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/main.js b/client/src/main.js index b94286cb..f5db5faa 100644 --- a/client/src/main.js +++ b/client/src/main.js @@ -34,7 +34,7 @@ Vue.config.productionTip = false; // Vue.prototype.$hostname = Vue.config.productionTip // ? 'http://localhost:5000' // : 'http://localhost:5000'; -Vue.prototype.$hostname = 'http://localhost:5000'; +Vue.prototype.$hostname = 'https://app.1gency.ee'; Vue.prototype.appConfig = config; Vue.component('Wrapper', Wrapper); From 0b43a1062f40e42f4a3cbab2e4db26accf319433 Mon Sep 17 00:00:00 2001 From: Khvatov Dmitry Date: Wed, 12 Jul 2023 21:24:41 +0200 Subject: [PATCH 2/7] Docker image versioning --- Makefile | 27 +++++++++++++++++++++++++++ client/Dockerfile | 2 ++ version.txt | 1 + 3 files changed, 30 insertions(+) create mode 100644 version.txt diff --git a/Makefile b/Makefile index 72482b5c..2ae2d080 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ DOCKER-COMPOSE-FILE=./docker-compose.yml NOW := `date +%Y-%m-%d_%H%M%S` EXISTING_DUMP_FILE_NAME := existing-${NOW}.bak +VERSION_FILE = version.txt FILE="" @@ -35,7 +36,33 @@ stop: @docker-compose -f ${DOCKER-COMPOSE-FILE} stop db build: stop + $(eval VERSION=$(shell cat $(VERSION_FILE))) + $(eval NEW_VERSION=$(shell echo $$(( $(VERSION) + 1 )))) + echo $(NEW_VERSION) > $(VERSION_FILE) docker-compose -f ${DOCKER-COMPOSE-FILE} build --no-cache --force-rm + docker tag 1gency-app-backend:latest 1gency-app-backend:$(NEW_VERSION) + docker tag 1gency-app-client:latest 1gency-app-client:$(NEW_VERSION) + docker tag 1gency-app-piler:latest 1gency-app-piler:$(NEW_VERSION) + +push: + # Get version + $(eval VERSION=$(shell cat version.txt)) + # Tag and push backend image + docker tag 1gency-app-backend visitors/1gency-app:backend-$(VERSION) + docker push visitors/1gency-app:backend-$(VERSION) + # Tag and push client image + docker tag 1gency-app-client visitors/1gency-app:client-$(VERSION) + docker push visitors/1gency-app:client-$(VERSION) + # Tag and push piler image + docker tag 1gency-app-piler visitors/1gency-app:piler-$(VERSION) + docker push visitors/1gency-app:piler-$(VERSION) + + +pull: + $(eval VERSION=$(shell cat version.txt)) + docker pull visitors/1gency-app:backend-$(VERSION) + docker pull visitors/1gency-app:client-$(VERSION) + docker pull visitors/1gency-app:piler-$(VERSION) ################################################################################ diff --git a/client/Dockerfile b/client/Dockerfile index efd5695c..16ef3aed 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,6 +1,8 @@ FROM node:20 AS build WORKDIR /app/client +ENV NODE_OPTIONS=--openssl-legacy-provider + RUN apt-get update && apt-get upgrade -y --no-install-recommends \ && npm i -g npm diff --git a/version.txt b/version.txt new file mode 100644 index 00000000..1e8b3149 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +6 From 3e643fefb3019918b6b8eb814bd9a079eca1e0eb Mon Sep 17 00:00:00 2001 From: Khvatov Dmitry Date: Wed, 12 Jul 2023 21:50:01 +0200 Subject: [PATCH 3/7] Update dockerfiles, makefile --- Makefile | 68 +++++++++++++++++------------------------- docker-compose.dev.yml | 4 --- docker-compose.yml | 4 --- version.txt | 2 +- 4 files changed, 28 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index 2ae2d080..281fd7ab 100644 --- a/Makefile +++ b/Makefile @@ -22,39 +22,31 @@ help: @echo " make demo - start containers with latest demo (anonymized) database" @echo " make schema - auto-generation database schema from json file (see backend/src/parser/README.md)" - +up: start start: - @docker ps | grep silver-bassoon-db > /dev/null || docker-compose -f ${DOCKER-COMPOSE-FILE} up -d db - @docker ps | grep silver-bassoon-backend > /dev/null || docker-compose -f ${DOCKER-COMPOSE-FILE} up -d backend - @docker ps | grep silver-bassoon-piler > /dev/null || docker-compose -f ${DOCKER-COMPOSE-FILE} up -d piler - @docker ps | grep silver-bassoon-client > /dev/null || docker-compose -f ${DOCKER-COMPOSE-FILE} up -d client + @docker compose -f ${DOCKER-COMPOSE-FILE} up -d db backend piler client +down: stop stop: - @docker-compose -f ${DOCKER-COMPOSE-FILE} stop client - @docker-compose -f ${DOCKER-COMPOSE-FILE} stop piler - @docker-compose -f ${DOCKER-COMPOSE-FILE} stop backend - @docker-compose -f ${DOCKER-COMPOSE-FILE} stop db + @docker compose -f ${DOCKER-COMPOSE-FILE} down build: stop $(eval VERSION=$(shell cat $(VERSION_FILE))) $(eval NEW_VERSION=$(shell echo $$(( $(VERSION) + 1 )))) echo $(NEW_VERSION) > $(VERSION_FILE) - docker-compose -f ${DOCKER-COMPOSE-FILE} build --no-cache --force-rm - docker tag 1gency-app-backend:latest 1gency-app-backend:$(NEW_VERSION) - docker tag 1gency-app-client:latest 1gency-app-client:$(NEW_VERSION) - docker tag 1gency-app-piler:latest 1gency-app-piler:$(NEW_VERSION) + docker compose -f ${DOCKER-COMPOSE-FILE} build --no-cache --force-rm push: # Get version $(eval VERSION=$(shell cat version.txt)) # Tag and push backend image - docker tag 1gency-app-backend visitors/1gency-app:backend-$(VERSION) + docker tag 1gency-app-backend:latest visitors/1gency-app:backend-$(VERSION) docker push visitors/1gency-app:backend-$(VERSION) # Tag and push client image - docker tag 1gency-app-client visitors/1gency-app:client-$(VERSION) + docker tag 1gency-app-client:latest visitors/1gency-app:client-$(VERSION) docker push visitors/1gency-app:client-$(VERSION) # Tag and push piler image - docker tag 1gency-app-piler visitors/1gency-app:piler-$(VERSION) + docker tag 1gency-app-piler:latest visitors/1gency-app:piler-$(VERSION) docker push visitors/1gency-app:piler-$(VERSION) @@ -79,9 +71,9 @@ schema: real_backup: @test -d backend/data || mkdir backend/data @echo ${EXISTING_DUMP_FILE_NAME} > /tmp/current_export_file_name.txt - @docker ps | grep silver-bassoon-db > /dev/null || docker-compose -f ${DOCKER-COMPOSE-FILE} up -d db - @docker exec -it silver-bassoon-db pg_dump -U python upwork_tools -p 5434 > backend/data/`cat /tmp/current_export_file_name.txt` - @( cd backend/data && ln -sf ./`cat /tmp/current_export_file_name.txt` ./latest.bak ) + @docker compose -f ${DOCKER-COMPOSE-FILE} up -d db + @docker compose -f ${DOCKER-COMPOSE-FILE} exec -T db pg_dump -U python upwork_tools -p 5434 > backend/data/$(shell cat /tmp/current_export_file_name.txt) + @( cd backend/data && ln -sf ./$(shell cat /tmp/current_export_file_name.txt) ./latest.bak ) @rm -f /tmp/current_export_file_name.txt backup: real_backup @@ -98,38 +90,33 @@ dump: real_backup ################################################################################ create-demo-db: real_backup - @docker exec -it silver-bassoon-backend ./commands.py anonymize -# Backup полученного анонимизированного дампа - @docker exec -it silver-bassoon-db pg_dump -U python upwork_tools -p 5434 > backend/anonymized-database.bak + @docker compose -f ${DOCKER-COMPOSE-FILE} exec -T backend ./commands.py anonymize + @docker compose -f ${DOCKER-COMPOSE-FILE} exec -T db pg_dump -U python upwork_tools -p 5434 > backend/anonymized-database.bak @cp backend/anonymized-database.bak backend/data/anonymized-${NOW}.bak - @make start - @echo "** Database has been anonymized ** " + @docker compose -f ${DOCKER-COMPOSE-FILE} up -d + @echo "** Database has been anonymized **" demo: @make import FILE=backend/anonymized-database.bak - ################################################################################ # Импорт произвольного дампа в контейнер # ################################################################################ + import-v1: stop @if [ -z ${FILE} ]; then ( echo "Usage: make import FILE=some_file_for_import"; exit 1; ) fi @if [ ! -f ${FILE} -a ! -h ${FILE} ]; then ( echo "File ${FILE} not found"; exit 1 ) fi - # Оставляем гарантированно только один контейнер, db (совместно с операцией stop). - @docker ps | grep silver-bassoon-db > /dev/null || docker-compose -f ${DOCKER-COMPOSE-FILE} up -d db + @docker compose -f ${DOCKER-COMPOSE-FILE} up -d db @echo "Copy db file to container..." - @docker cp -L ${FILE} silver-bassoon-db:/tmp/imported_dump.bak || exit 1 - @echo "recreate db in container..." - @docker exec -it silver-bassoon-db psql -U python -d postgres -p 5434 -c 'drop database if exists upwork_tools;' - @docker exec -it silver-bassoon-db psql -U python -d postgres -p 5434 -c 'create database upwork_tools;' + @docker compose -f ${DOCKER-COMPOSE-FILE} cp -L ${FILE} db:/tmp/imported_dump.bak || exit 1 + @echo "Recreate db in container..." + @docker compose -f ${DOCKER-COMPOSE-FILE} exec -T db psql -U python -d postgres -p 5434 -c 'drop database if exists upwork_tools;' + @docker compose -f ${DOCKER-COMPOSE-FILE} exec -T db psql -U python -d postgres -p 5434 -c 'create database upwork_tools;' @echo "Import db into container..." - @echo "psql -U python -d upwork_tools -p 5434 < /tmp/imported_dump.bak" > /tmp/recreate_in_docker.sh - @chmod a+x /tmp/recreate_in_docker.sh - @docker cp /tmp/recreate_in_docker.sh silver-bassoon-db:/tmp - @docker exec -it silver-bassoon-db bash /tmp/recreate_in_docker.sh + @docker compose -f ${DOCKER-COMPOSE-FILE} exec -T db bash -c 'psql -U python -d upwork_tools -p 5434 < /tmp/imported_dump.bak' @echo "** data/latest.bak imported into database container. **" @make start - @echo "** all containers has been started. **" + @echo "** all containers have been started. **" import: @if [ -z ${FILE} ]; then echo "Usage: make import FILE=some_file_for_import"; exit 1; fi @@ -141,14 +128,13 @@ import: @echo "Copy db file to container..." @docker compose -f ${DOCKER-COMPOSE-FILE} cp -L ${FILE} db:/tmp/imported_dump.bak || exit 1 @echo "Drop old db in container..." - @docker compose -f ${DOCKER-COMPOSE-FILE} exec db bash -c 'PGPASSWORD=python psql -U python -d postgres -p 5434 -c "drop database if exists upwork_tools;"' + @docker compose -f ${DOCKER-COMPOSE-FILE} exec -T db bash -c 'PGPASSWORD=python psql -U python -d postgres -p 5434 -c "drop database if exists upwork_tools;"' @echo "Initialize blank db in container..." - @docker compose -f ${DOCKER-COMPOSE-FILE} exec db psql -U python -d postgres -p 5434 -c 'create database upwork_tools;' + @docker compose -f ${DOCKER-COMPOSE-FILE} exec -T db psql -U python -d postgres -p 5434 -c 'create database upwork_tools;' @echo "Import db into container..." - @docker compose -f ${DOCKER-COMPOSE-FILE} exec db bash -c 'psql -U python -d upwork_tools -p 5434 < /tmp/imported_dump.bak' + @docker compose -f ${DOCKER-COMPOSE-FILE} exec -T db bash -c 'psql -U python -d upwork_tools -p 5434 < /tmp/imported_dump.bak' @docker compose -f ${DOCKER-COMPOSE-FILE} up -d - @echo "** all containers has been started. **" - + @echo "** all containers have been started. **" ################################################################################ # Импорт последнего существующего дампа в контейнер # diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 1efaeddd..fbb8601a 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -2,7 +2,6 @@ version: '3.9' services: client: - container_name: silver-bassoon-client build: context: client dockerfile: Dockerfile.dev @@ -14,7 +13,6 @@ services: - backend backend: - container_name: silver-bassoon-backend build: context: backend args: @@ -31,7 +29,6 @@ services: FLASK_DEBUG: true piler: - container_name: silver-bassoon-piler build: context: piler volumes: @@ -42,7 +39,6 @@ services: - backend db: - container_name: silver-bassoon-db image: postgres environment: POSTGRES_USER: python diff --git a/docker-compose.yml b/docker-compose.yml index b97df5a8..8708029a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,6 @@ version: '3.7' services: client: - container_name: silver-bassoon-client build: context: client ports: @@ -11,7 +10,6 @@ services: - backend backend: - container_name: silver-bassoon-backend build: context: backend volumes: @@ -23,7 +21,6 @@ services: command: 'gunicorn --bind 0.0.0.0:5000 app:app' piler: - container_name: silver-bassoon-piler build: context: piler volumes: @@ -34,7 +31,6 @@ services: - backend db: - container_name: silver-bassoon-db image: postgres environment: POSTGRES_USER: python diff --git a/version.txt b/version.txt index 1e8b3149..7f8f011e 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -6 +7 From 125817f7b7a0e0f3bfc43d952dd94d438647fd2b Mon Sep 17 00:00:00 2001 From: Khvatov Dmitry Date: Wed, 12 Jul 2023 22:27:18 +0200 Subject: [PATCH 4/7] Fix docker setup --- Makefile | 3 ++- docker-compose.dev.yml | 3 +++ docker-compose.yml | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 281fd7ab..df272750 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ DOCKER-COMPOSE-FILE=./docker-compose.yml NOW := `date +%Y-%m-%d_%H%M%S` EXISTING_DUMP_FILE_NAME := existing-${NOW}.bak VERSION_FILE = version.txt +IMAGE_VERSION := $(shell cat $(VERSION_FILE)) FILE="" @@ -24,7 +25,7 @@ help: up: start start: - @docker compose -f ${DOCKER-COMPOSE-FILE} up -d db backend piler client + IMAGE_VERSION=$(IMAGE_VERSION) docker compose -f ${DOCKER-COMPOSE-FILE} up -d db backend piler client down: stop stop: diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index fbb8601a..664e5692 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -2,6 +2,7 @@ version: '3.9' services: client: + image: visitors/1gency-app:client-${IMAGE_VERSION} build: context: client dockerfile: Dockerfile.dev @@ -13,6 +14,7 @@ services: - backend backend: + image: visitors/1gency-app:backend-${IMAGE_VERSION} build: context: backend args: @@ -29,6 +31,7 @@ services: FLASK_DEBUG: true piler: + image: visitors/1gency-app:piler-${IMAGE_VERSION} build: context: piler volumes: diff --git a/docker-compose.yml b/docker-compose.yml index 8708029a..efdff228 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.7' services: - client: + image: visitors/1gency-app:client-${IMAGE_VERSION} build: context: client ports: @@ -10,6 +10,7 @@ services: - backend backend: + image: visitors/1gency-app:backend-${IMAGE_VERSION} build: context: backend volumes: @@ -21,6 +22,7 @@ services: command: 'gunicorn --bind 0.0.0.0:5000 app:app' piler: + image: visitors/1gency-app:piler-${IMAGE_VERSION} build: context: piler volumes: From e55ba528198de56a258e2593fa8dd1764b622fda Mon Sep 17 00:00:00 2001 From: Khvatov Dmitry Date: Wed, 12 Jul 2023 22:47:31 +0200 Subject: [PATCH 5/7] Fix docker setup --- Makefile | 2 +- version.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index df272750..f8740b2f 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ build: stop $(eval VERSION=$(shell cat $(VERSION_FILE))) $(eval NEW_VERSION=$(shell echo $$(( $(VERSION) + 1 )))) echo $(NEW_VERSION) > $(VERSION_FILE) - docker compose -f ${DOCKER-COMPOSE-FILE} build --no-cache --force-rm + IMAGE_VERSION=$(NEW_VERSION) docker compose -f ${DOCKER-COMPOSE-FILE} build --no-cache --force-rm push: # Get version diff --git a/version.txt b/version.txt index 7f8f011e..f599e28b 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -7 +10 From 694ef3f246335294887fe42d938490eeae15da49 Mon Sep 17 00:00:00 2001 From: Khvatov Dmitry Date: Wed, 12 Jul 2023 23:19:01 +0200 Subject: [PATCH 6/7] Don't do apt-get upgrade --- client/Dockerfile | 3 +-- client/Dockerfile.dev | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/Dockerfile b/client/Dockerfile index 16ef3aed..283bb3da 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -3,8 +3,7 @@ WORKDIR /app/client ENV NODE_OPTIONS=--openssl-legacy-provider -RUN apt-get update && apt-get upgrade -y --no-install-recommends \ - && npm i -g npm +RUN apt-get update && npm i -g npm COPY package*.json ./ COPY patches ./patches diff --git a/client/Dockerfile.dev b/client/Dockerfile.dev index 3de63d3b..2f267a08 100644 --- a/client/Dockerfile.dev +++ b/client/Dockerfile.dev @@ -1,8 +1,9 @@ -FROM node:14 AS build +FROM node:20 AS build WORKDIR /app/client -RUN apt-get update && apt-get upgrade -y --no-install-recommends \ - && npm i -g npm +ENV NODE_OPTIONS=--openssl-legacy-provider + +RUN apt-get update && npm i -g npm COPY package*.json ./ COPY patches ./patches From dabef32efece785a5ca6583a43c9e71a67c4e529 Mon Sep 17 00:00:00 2001 From: Khvatov Dmitry Date: Mon, 4 Dec 2023 23:39:12 +0100 Subject: [PATCH 7/7] Fix dockerfiles --- client/Dockerfile | 4 ---- client/Dockerfile.dev | 4 ---- version.txt | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/client/Dockerfile b/client/Dockerfile index c8e41218..e5dbd7c9 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,10 +1,6 @@ FROM node:16 AS build WORKDIR /app/client -ENV NODE_OPTIONS=--openssl-legacy-provider - -RUN apt-get update && npm i -g npm - COPY package*.json ./ COPY patches ./patches RUN npm install diff --git a/client/Dockerfile.dev b/client/Dockerfile.dev index c66412fb..a4983e17 100644 --- a/client/Dockerfile.dev +++ b/client/Dockerfile.dev @@ -1,10 +1,6 @@ FROM node:16 AS build WORKDIR /app/client -ENV NODE_OPTIONS=--openssl-legacy-provider - -RUN apt-get update && npm i -g npm - COPY package*.json ./ COPY patches ./patches RUN npm install diff --git a/version.txt b/version.txt index f599e28b..8351c193 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -10 +14