From 6e576919abab8b23f582737abbd50f5a49ba31f6 Mon Sep 17 00:00:00 2001 From: louiscklaw Date: Sun, 11 May 2025 07:59:35 +0800 Subject: [PATCH] init docker cofig, --- 002_source/.env | 14 +++ 002_source/.gitignore | 4 + 002_source/README.md | 74 +++++++++++++++ 002_source/docker-compose.dev.yml | 33 +++++++ 002_source/docker-compose.yml | 149 ++++++++++++++++++++++++++++++ 002_source/scripts/backup.sh | 19 ++++ 002_source/scripts/dc_build.sh | 36 ++++++++ 002_source/scripts/dc_dev.sh | 17 ++++ 002_source/scripts/dc_up.sh | 20 ++++ 002_source/scripts/run.sh | 6 ++ 10 files changed, 372 insertions(+) create mode 100644 002_source/.env create mode 100644 002_source/.gitignore create mode 100644 002_source/README.md create mode 100644 002_source/docker-compose.dev.yml create mode 100644 002_source/docker-compose.yml create mode 100755 002_source/scripts/backup.sh create mode 100755 002_source/scripts/dc_build.sh create mode 100755 002_source/scripts/dc_dev.sh create mode 100755 002_source/scripts/dc_up.sh create mode 100755 002_source/scripts/run.sh diff --git a/002_source/.env b/002_source/.env new file mode 100644 index 0000000..4900e4a --- /dev/null +++ b/002_source/.env @@ -0,0 +1,14 @@ +# THIS IS env file for use with docker-compose.yml + +# cms + +# doc + +# ionic_mobile + +# api_ts + +# pocketbase +PB_HOSTNAME=pocketbase +PB_USERNAME=admin@123.com +PB_PASSWORD=Aa12345678 diff --git a/002_source/.gitignore b/002_source/.gitignore new file mode 100644 index 0000000..5f5a1a4 --- /dev/null +++ b/002_source/.gitignore @@ -0,0 +1,4 @@ +**/*.del +**/*.log +**/_archive +**/_del diff --git a/002_source/README.md b/002_source/README.md new file mode 100644 index 0000000..e9c2e7c --- /dev/null +++ b/002_source/README.md @@ -0,0 +1,74 @@ +# README + +## to start production + +```bash +# start docker before hand +$ ./dc_build.sh + +$ ./dc_up.sh +``` + +## to start develop + +```bash +# +$ ./dc_build.sh +$ ./dc_dev.sh +$ docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d pocketbase api_ts --remove-orphans +$ docker compose logs -f pocketbase api_ts +``` + +## test api endpoint + +```bash +# browse to http://localhost:3000/helloworld +``` + +```bash +# start docker before hand + +$ cd 002_source +$ ./dev.sh + +# docker containers up +``` + +--- + +## deprecated + +```bash +# mobile +$ cd 002_source/mobile +$ pnpm run dev + +# cms +$ cd 002_source/cms +$ npm run dev +``` + +ideation +prototyping +testing +production deployment +evaluation +monitoring + +## addresses + +``` +mobile: +http://localhost:5173 + +pocketbase: +http://localhost:8090/_ + +cms: +http://localhost:3000 + +documentation +http://localhost:3001 +``` + +extend to vocabularies diff --git a/002_source/docker-compose.dev.yml b/002_source/docker-compose.dev.yml new file mode 100644 index 0000000..f797f2d --- /dev/null +++ b/002_source/docker-compose.dev.yml @@ -0,0 +1,33 @@ +services: + cms: + environment: + - NODE_ENV=development + # command: "sleep infinity" + deploy: + resources: + limits: + cpus: "1" + + doc: + environment: + - NODE_ENV=development + deploy: + resources: + limits: + cpus: "1" + + ionic_mobile: + environment: + - NODE_ENV=development + deploy: + resources: + limits: + cpus: "1" + + api_ts: + environment: + - NODE_ENV=development + deploy: + resources: + limits: + cpus: "1" diff --git a/002_source/docker-compose.yml b/002_source/docker-compose.yml new file mode 100644 index 0000000..0e96263 --- /dev/null +++ b/002_source/docker-compose.yml @@ -0,0 +1,149 @@ +volumes: + shared: + dist: + +services: + cms: + image: 192.168.10.61:5000/cms_ubuntu + # build: ./cms + env_file: + - .env + volumes: + - ./cms:/app + ports: + - 3000:3000 + working_dir: /app + command: ./scripts/docker/entrypoint.sh + depends_on: + pocketbase: + condition: service_healthy + healthcheck: + #optional (recommended) since v0.10.0 + test: wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1 + interval: 5s + timeout: 5s + retries: 5 + deploy: + resources: + limits: + cpus: "0.5" + reservations: + cpus: "0.01" + + doc: + build: ./doc + env_file: + - .env + volumes: + - ./doc:/app + ports: + - 3001:3000 + working_dir: /app + command: ./scripts/docker/entrypoint.sh + healthcheck: + #optional (recommended) since v0.10.0 + test: wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1 + interval: 5s + timeout: 5s + retries: 5 + + deploy: + resources: + limits: + cpus: "0.5" + reservations: + cpus: "0.01" + + ionic_mobile: + # image: node:20-bullseye-slim + # build: ./ionic_mobile + image: 192.168.10.61:5000/ionic_mobile_ubuntu + # user: 1000:1000 + env_file: + - .env + volumes: + - ./ionic_mobile:/app + ports: + - 5173:5173 + working_dir: /app + command: ./scripts/docker/entrypoint.sh + depends_on: + pocketbase: + condition: service_healthy + healthcheck: + #optional (recommended) since v0.10.0 + test: wget --no-verbose --tries=1 --spider http://localhost:5173 || exit 1 + interval: 5s + timeout: 5s + retries: 5 + + deploy: + resources: + limits: + cpus: "0.5" + reservations: + cpus: "0.01" + + api_ts: + image: 192.168.10.61:5000/api_ts_ubuntu + # build: ./api_ts + volumes: + - ./api_ts:/app + working_dir: /app + # env_file: + # - .env + environment: + - NODE_ENV=production + - PB_HOSTNAME=pocketbase + - PB_USERNAME=admin@123.com + - PB_PASSWORD=Aa12345678 + ports: + - 8080:3000 + # command: sleep infinity + command: ./entrypoint.sh + # depends_on: + # pocketbase: + # condition: service_healthy + # healthcheck: + # #optional (recommended) since v0.10.0 + # test: wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1 + # interval: 5s + # timeout: 5s + # retries: 5 + + deploy: + resources: + limits: + cpus: 0.5 + reservations: + cpus: 0.01 + + pocketbase: + # image: ghcr.io/muchobien/pocketbase:latest + build: + context: ./pocketbase/docker + args: + - VERSION=0.26.6 # Specify the PocketBase version here + # hostname: pocketbase + restart: always + # environment: + # ENCRYPTION: example #optional + ports: + - 8090:8090 + volumes: + - ./pocketbase/volumes/pb_data:/pb_data + - ./pocketbase/pb_hooks:/pb_hooks + - ./pocketbase/pb_migrations:/pb_migrations + # healthcheck: + # #optional (recommended) since v0.10.0 + # test: wget --no-verbose --tries=1 --spider http://localhost:8090/api/health || exit 1 + # interval: 5s + # timeout: 5s + # retries: 5 + + deploy: + resources: + limits: + cpus: 0.5 + reservations: + cpus: 0.01 diff --git a/002_source/scripts/backup.sh b/002_source/scripts/backup.sh new file mode 100755 index 0000000..c7e5263 --- /dev/null +++ b/002_source/scripts/backup.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -ex + +# GLOBAL_EXCLUDE="--exclude={'**/.git','**/node_modules','**/.pnpm','**//**'}" + +# tar -zcvf _archive/cms/018.tar.gz \ +# --exclude "node_modules" \ +# --exclude ".next" \ +# cms + +rsync -avzh \ + --exclude ".next" \ + --exclude "node_modules" \ + --exclude ".pnpm" \ + --exclude ".git" \ + cms _archive/006_cms_start_categories_edit + +echo "done" diff --git a/002_source/scripts/dc_build.sh b/002_source/scripts/dc_build.sh new file mode 100755 index 0000000..5f1f808 --- /dev/null +++ b/002_source/scripts/dc_build.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -ex + +# cms_ubuntu use nvm docker image +cd ../005_references/nvm +# docker build -t 192.168.10.61:5000/nvm_ubuntu:latest . +# docker tag nvm_ubuntu 192.168.10.61:5000/nvm_ubuntu + +# docker build -t nvm_ubuntu:latest . +# docker run -it nvm_ubuntu:latest bash +# docker run -it 192.168.10.61:5000/nvm_ubuntu:latest bash +cd - + +cd ./cms +docker build -t 192.168.10.61:5000/cms_ubuntu:latest . +cd - + +# ionic_mobile +cd ./ionic_mobile +docker build -t 192.168.10.61:5000/ionic_mobile_ubuntu:latest . +cd - + +# api_ts +cd ./api_ts +docker build -t 192.168.10.61:5000/api_ts_ubuntu:latest . +cd - + +# # pocketbase + +# echo "done" + +docker push 192.168.10.61:5000/nvm_ubuntu:latest +docker push 192.168.10.61:5000/cms_ubuntu:latest +docker push 192.168.10.61:5000/api_ts_ubuntu:latest +docker push 192.168.10.61:5000/ionic_mobile_ubuntu:latest diff --git a/002_source/scripts/dc_dev.sh b/002_source/scripts/dc_dev.sh new file mode 100755 index 0000000..dc3927e --- /dev/null +++ b/002_source/scripts/dc_dev.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -ex + +docker compose kill +docker compose down + +docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d pocketbase api_ts --remove-orphans +# docker compose logs -f pocketbase api_ts + +echo "done" + + +echo "please run yourself !!!!" +echo "nodemon -w /pb_hooks --exec "pocketbase seed"" +echo "" +docker compose exec -it pocketbase sh diff --git a/002_source/scripts/dc_up.sh b/002_source/scripts/dc_up.sh new file mode 100755 index 0000000..40637d0 --- /dev/null +++ b/002_source/scripts/dc_up.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -ex + +# docker compose build + +# cd cms +# # nvm use 18 +# npm run build +# cd - + +# cd ionic_mobile +# npm run build +# cd - + +docker compose up -d + +docker compose logs -f + +echo "done" diff --git a/002_source/scripts/run.sh b/002_source/scripts/run.sh new file mode 100755 index 0000000..182fb12 --- /dev/null +++ b/002_source/scripts/run.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -ex + +docker compose exec -it cms bash + +echo "done"