From 5ecd86ba02983b734faa9cf6db5a60e3ec4cc943 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 4 Jul 2019 11:56:52 +0200 Subject: [PATCH] misc: naming refactor on build process --- .gitignore | 4 +- .../{release.backend => backend}/Dockerfile | 0 .../entrypoint.sh | 0 docker/docker-compose.yml | 26 ++-- .../{release.frontend => frontend}/Dockerfile | 0 .../nginx/README.md | 0 .../nginx/conf.d/default.conf | 0 .../nginx/conf.d/misc.conf | 0 frontend/scripts/build-develop.sh | 3 - .../{build-release.sh => build-production.sh} | 3 - manage.sh | 124 +++++++++--------- 11 files changed, 76 insertions(+), 84 deletions(-) rename docker/{release.backend => backend}/Dockerfile (100%) rename docker/{release.backend => backend}/entrypoint.sh (100%) rename docker/{release.frontend => frontend}/Dockerfile (100%) rename docker/{release.frontend => frontend}/nginx/README.md (100%) rename docker/{release.frontend => frontend}/nginx/conf.d/default.conf (100%) rename docker/{release.frontend => frontend}/nginx/conf.d/misc.conf (100%) rename frontend/scripts/{build-release.sh => build-production.sh} (58%) diff --git a/.gitignore b/.gitignore index a651ba5cf..8ab4304a6 100644 --- a/.gitignore +++ b/.gitignore @@ -26,8 +26,8 @@ node_modules /frontend/resources/public/js /frontend/resources/public/view /frontend/resources/public/index.html -/docker/release.frontend/dist -/docker/release.backend/dist +/docker/frontend/dist +/docker/backend/dist /media /deploy /web diff --git a/docker/release.backend/Dockerfile b/docker/backend/Dockerfile similarity index 100% rename from docker/release.backend/Dockerfile rename to docker/backend/Dockerfile diff --git a/docker/release.backend/entrypoint.sh b/docker/backend/entrypoint.sh similarity index 100% rename from docker/release.backend/entrypoint.sh rename to docker/backend/entrypoint.sh diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index d6dcb9154..a5db3ffbc 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -3,7 +3,7 @@ version: "3" volumes: backend_m2: backend_data: - db_data: + pgdb_data: networks: default: @@ -13,7 +13,7 @@ networks: - subnet: 172.177.10.0/24 services: - uxdb: + pgdb: image: postgres:11 restart: always ports: @@ -24,16 +24,15 @@ services: - POSTGRES_USER=uxbox - POSTGRES_PASSWORD=uxbox_postgres_password volumes: - - db_data:/var/lib/postgresql/data + - pgdb_data:/var/lib/postgresql/data # - /etc/localtime:/etc/localtime:ro # - /etc/timezone:/etc/timezone:ro - uxbackend: - image: uxbox-production-backend:latest - # container_name: uxbackend + backend: + image: uxbox-backend-production:latest restart: always depends_on: - - uxdb + - pgdb ports: - 6060 volumes: @@ -67,12 +66,11 @@ services: # Security setup - UXBOX_SECRET="foobar" - uxfrontend: - image: uxbox-production-frontend:latest - #hostname: uxbox.io + frontend: + image: uxbox-frontend-production:latest restart: always depends_on: - - uxbackend + - backend ports: - 8080:8080 volumes: @@ -80,11 +78,11 @@ services: # - /etc/localtime:/etc/localtime:ro # - /etc/timezone:/etc/timezone:ro - uxfrontend-dev: - image: uxbox-develop-frontend:latest + frontend-dev: + image: uxbox-frontend-develop:latest restart: always depends_on: - - uxbackend + - backend ports: - 8081:8080 volumes: diff --git a/docker/release.frontend/Dockerfile b/docker/frontend/Dockerfile similarity index 100% rename from docker/release.frontend/Dockerfile rename to docker/frontend/Dockerfile diff --git a/docker/release.frontend/nginx/README.md b/docker/frontend/nginx/README.md similarity index 100% rename from docker/release.frontend/nginx/README.md rename to docker/frontend/nginx/README.md diff --git a/docker/release.frontend/nginx/conf.d/default.conf b/docker/frontend/nginx/conf.d/default.conf similarity index 100% rename from docker/release.frontend/nginx/conf.d/default.conf rename to docker/frontend/nginx/conf.d/default.conf diff --git a/docker/release.frontend/nginx/conf.d/misc.conf b/docker/frontend/nginx/conf.d/misc.conf similarity index 100% rename from docker/release.frontend/nginx/conf.d/misc.conf rename to docker/frontend/nginx/conf.d/misc.conf diff --git a/frontend/scripts/build-develop.sh b/frontend/scripts/build-develop.sh index 942fdb5b7..f20918be9 100755 --- a/frontend/scripts/build-develop.sh +++ b/frontend/scripts/build-develop.sh @@ -6,6 +6,3 @@ npm ci npm run dist:clean || exit 1; npm run build:assets || exit 1; npm run build:all || exit 1; -# npm run build:main || exit 1; -# npm run build:view || exit 1; -# npm run build:worker || exit 1; diff --git a/frontend/scripts/build-release.sh b/frontend/scripts/build-production.sh similarity index 58% rename from frontend/scripts/build-release.sh rename to frontend/scripts/build-production.sh index 793a94447..4bdb3af67 100755 --- a/frontend/scripts/build-release.sh +++ b/frontend/scripts/build-production.sh @@ -6,6 +6,3 @@ npm ci npm run dist:clean || exit 1; npm run dist:assets || exit 1; npm run dist:all || exit 1; -# npm run dist:main || exit 1; -# npm run dist:view || exit 1; -# npm run dist:worker || exit 1; diff --git a/manage.sh b/manage.sh index 2ed2fdb5e..23d80a0d5 100755 --- a/manage.sh +++ b/manage.sh @@ -14,7 +14,7 @@ function remove-devenv-images { docker images $IMGNAME -q | awk '{print $3}' | xargs --no-run-if-empty docker rmi } -function build-devenv { +function build-devenv-image { echo "Building development image $IMGNAME:$REV..." docker build --rm=true \ -t $IMGNAME:$REV \ @@ -24,15 +24,15 @@ function build-devenv { docker/devenv } -function build-devenv-if-not-exists { +function build-devenv-image-if-not-exists { if [[ ! $(docker images $IMGNAME:$REV -q) ]]; then - build-devenv + build-devenv-image fi } function run-devenv { kill-devenv-container; - build-devenv-if-not-exists; + build-devenv-image-if-not-exists; mkdir -p $HOME/.m2 rm -rf ./frontend/node_modules @@ -60,7 +60,7 @@ function run-all-tests { } function run-frontend-tests { - build-devenv-if-not-exists; + build-devenv-image-if-not-exists; CONTAINER=$IMGNAME:latest @@ -73,7 +73,7 @@ function run-frontend-tests { } function run-backend-tests { - build-devenv-if-not-exists; + build-devenv-image-if-not-exists; CONTAINER=$IMGNAME:latest @@ -85,7 +85,7 @@ function run-backend-tests { } function build-frontend-local { - build-devenv-if-not-exists; + build-devenv-image-if-not-exists; mkdir -p $HOME/.m2 rm -rf ./frontend/node_modules @@ -103,34 +103,34 @@ function build-frontend-local { $CONTAINER ./scripts/build-$BUILD_TYPE.sh } -function build-release-frontend-image { - build-frontend-local "release" || exit 1; - rm -rf docker/release.frontend/dist || exit 1; - cp -vr frontend/dist docker/release.frontend/ || exit 1; +function build-frontend-production-image { + build-frontend-local "production" || exit 1; + rm -rf docker/frontend/dist || exit 1; + cp -vr frontend/dist docker/frontend/ || exit 1; docker build --rm=true \ - -t uxbox-production-frontend:$REV \ - -t uxbox-production-frontend:latest \ - docker/release.frontend/; + -t uxbox-frontend-production:$REV \ + -t uxbox-frontend-production:latest \ + docker/frontend/; - rm -rf docker/release.frontend/dist || exit 1; + rm -rf docker/frontend/dist || exit 1; } -function build-develop-frontend-image { +function build-frontend-develop-image { build-frontend-local "develop" || exit 1; - rm -rf docker/release.frontend/dist || exit 1; - cp -vr frontend/dist docker/release.frontend/ || exit 1; + rm -rf docker/frontend/dist || exit 1; + cp -vr frontend/dist docker/frontend/ || exit 1; docker build --rm=true \ - -t uxbox-develop-frontend:$REV \ - -t uxbox-develop-frontend:latest \ - docker/release.frontend/; + -t uxbox-frontend-develop:$REV \ + -t uxbox-frontend-develop:latest \ + docker/frontend/; - rm -rf docker/release.frontend/dist || exit 1; + rm -rf docker/frontend/dist || exit 1; } function build-backend-local { - echo "Prepare backend release..." + echo "Prepare backend dist..." rm -rf ./backend/dist @@ -143,66 +143,66 @@ function build-backend-local { ./backend/ ./backend/dist/ } -function build-release-backend-image { +function build-backend-production-image { build-backend-local || exit 1; - rm -rf docker/release.backend/dist || exit 1; - cp -vr backend/dist docker/release.backend/ || exit 1; + rm -rf docker/backend/dist || exit 1; + cp -vr backend/dist docker/backend/ || exit 1; docker build --rm=true \ - -t uxbox-production-backend:$REV \ - -t uxbox-production-backend:latest \ - docker/release.backend/; + -t uxbox-backend-production:$REV \ + -t uxbox-backend-production:latest \ + docker/backend/; - rm -rf docker/release.backend/dist || exit 1; + rm -rf docker/backend/dist || exit 1; } function build-images { - echo "Building frontend release image ..." - build-release-frontend-image || exit 1; + echo "Building frontend production image ..." + build-frontend-production-image || exit 1; echo "Building frontend develop image ..." - build-develop-frontend-image || exit 1; - echo "Building backend release image ..." - build-release-backend-image || exit 1; + build-frontend-develop-image || exit 1; + echo "Building backend production image ..." + build-backend-production-image || exit 1; } function run { - if [[ ! $(docker images uxbox-release-backend:latest) ]]; then - build-release-backend-image + if [[ ! $(docker images uxbox-backend-production:latest) ]]; then + build-production-backend-image fi - if [[ ! $(docker images uxbox-release-frontend:latest) ]]; then - build-release-frontend-image + if [[ ! $(docker images uxbox-frontend-production:latest) ]]; then + build-production-frontend-image fi - if [[ ! $(docker images uxbox-develop-frontend:latest) ]]; then + if [[ ! $(docker images uxbox-frontend-develop:latest) ]]; then build-develop-frontend-image fi echo "Running production images..." - sudo docker-compose -p uxbox -f ./docker/docker-compose.yml up -d + docker-compose -p uxbox -f ./docker/docker-compose.yml up -d } function stop { echo "Stoping containers..." - sudo docker-compose -p uxbox -f ./docker/docker-compose.yml stop -d + docker-compose -p uxbox -f ./docker/docker-compose.yml stop } function usage { echo "UXBOX build & release manager v$REV" echo "USAGE: $0 OPTION" echo "Options:" - echo "- clean Stop and clean up docker containers" - echo "- build-devenv Build docker container for development with tmux" - echo "- run-devenv Run (and build if necessary) development container (frontend at localhost:3449, backend at localhost:6060)" - echo "- run-all-tests Execute unit tests for both backend and frontend" - echo "- run-frontend-tests Execute unit tests for frontend only" - echo "- run-backend-tests Execute unit tests for backend only" - echo "- build-release-images Build 'production ready' docker images for both backend and frontend" - echo "- build-develop-frontend-image Build a 'develop' docker images for frontend only" - echo "- build-release-frontend-image Build a 'production ready' docker images for frontend only" - echo "- build-release-backend-image Build a 'production ready' docker images for backend only" - echo "- run Run 'production ready' docker compose" - echo "- stop Stop 'production ready' docker compose" + echo "- clean Stop and clean up docker containers" + echo "- build-devenv-image Build docker container for development with tmux" + echo "- run-devenv Run (and build if necessary) development container (frontend at localhost:3449, backend at localhost:6060)" + echo "- run-all-tests Execute unit tests for both backend and frontend" + echo "- run-frontend-tests Execute unit tests for frontend only" + echo "- run-backend-tests Execute unit tests for backend only" + echo "- build-images Build a 'release ready' docker images for both backend and frontend" + echo "- build-frontend-develop-image Build a 'release ready' docker image for frontend (develop build)" + echo "- build-frontend-production-image Build a 'release ready' docker images for frontend" + echo "- build-backend-production-image Build a 'release ready' docker images for backend" + echo "- run Run 'production ready' docker compose" + echo "- stop Stop 'production ready' docker compose" } case $1 in @@ -210,8 +210,8 @@ case $1 in kill-devenv-container remove-devenv-images ;; - build-devenv) - build-devenv + build-devenv-image) + build-devenv-image ;; run-devenv) run-devenv @@ -229,14 +229,14 @@ case $1 in build-images) build-images ;; - build-release-frontend-image) - build-release-frontend-image + build-frontend-develop-image) + build-frontend-develop-image; ;; - build-develop-frontend-image) - build-develop-frontend-image + build-frontend-production-image) + build-frontend-production-image; ;; - build-release-backend-image) - build-release-backend-image + build-backend-production-image) + build-backend-production-image; ;; run)