diff --git a/build-protos.sh b/build-protos.sh index a459b96..9b284c7 100755 --- a/build-protos.sh +++ b/build-protos.sh @@ -1,7 +1,5 @@ #!/bin/bash -PROTO_PATH=protos - SCRIPT_PATHS=("sorusora" "sorusora-ai") EXEC=build-protos.sh @@ -11,6 +9,6 @@ for path in "${SCRIPT_PATHS[@]}"; do pushd "${path}" > /dev/null || return chmod +x "${EXEC}" - ./"${EXEC}" "../${PROTO_PATH}" + ./"${EXEC}" popd > /dev/null || return done diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 4da1de4..45f5f77 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -4,7 +4,7 @@ services: sorusora: build: context: . - dockerfile: docker/sorusora/Dockerfile + dockerfile: sorusora/Dockerfile container_name: sorusora volumes: - ./sorusora/logs:/app/logs @@ -19,7 +19,7 @@ services: sorusora-ai: build: context: . - dockerfile: docker/sorusora-ai/Dockerfile + dockerfile: sorusora-ai/Dockerfile container_name: sorusora-ai volumes: - ./sorusora-ai/logs:/app/logs diff --git a/docker/sorusora-ai/Dockerfile b/docker/sorusora-ai/Dockerfile deleted file mode 100644 index 1d7b14c..0000000 --- a/docker/sorusora-ai/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -FROM ghcr.io/puppeteer/puppeteer:22.4.1 - -USER root - -SHELL ["/bin/bash", "-c"] - -ENV NODE_VERSION=21.6 - -ENV ROOT_PATH sorusora-ai - -ENV PROTO_PATH protos - -RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \ - && export NVM_DIR="$HOME/.nvm" \ - && [ -s "$NVM_DIR/nvm.sh" ] \ - && \. "$NVM_DIR/nvm.sh" \ - && [ -s "$NVM_DIR/bash_completion" ] \ - && \. "$NVM_DIR/bash_completion" \ - && nvm install $NODE_VERSION \ - && source $HOME/.bashrc \ - && nvm use $NODE_VERSION - -WORKDIR /app - -COPY ${ROOT_PATH}/package.json . - -RUN npm install - -COPY ${PROTO_PATH} ${PROTO_PATH} - -COPY ${ROOT_PATH}/build-protos.sh . - -RUN chmod +x build-protos.sh \ - && ./build-protos.sh ${PROTO_PATH} - -COPY ${ROOT_PATH} . - -RUN npm run build - -CMD ["npm", "start"] diff --git a/sorusora-ai/Dockerfile b/sorusora-ai/Dockerfile index d0f3ca3..1d7b14c 100644 --- a/sorusora-ai/Dockerfile +++ b/sorusora-ai/Dockerfile @@ -6,7 +6,9 @@ SHELL ["/bin/bash", "-c"] ENV NODE_VERSION=21.6 -ENV ROOT_PATH ../../sorusora-ai +ENV ROOT_PATH sorusora-ai + +ENV PROTO_PATH protos RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \ && export NVM_DIR="$HOME/.nvm" \ @@ -24,10 +26,15 @@ COPY ${ROOT_PATH}/package.json . RUN npm install -COPY ${ROOT_PATH} . +COPY ${PROTO_PATH} ${PROTO_PATH} + +COPY ${ROOT_PATH}/build-protos.sh . RUN chmod +x build-protos.sh \ - && ./build-protos.sh \ - && npm run build + && ./build-protos.sh ${PROTO_PATH} + +COPY ${ROOT_PATH} . + +RUN npm run build CMD ["npm", "start"] diff --git a/sorusora-ai/build-protos.sh b/sorusora-ai/build-protos.sh index 7e9ca7f..44050d9 100755 --- a/sorusora-ai/build-protos.sh +++ b/sorusora-ai/build-protos.sh @@ -1,10 +1,12 @@ #!/bin/bash -if [[ $# -ne 1 ]]; then - echo "Usage: $0 " - exit 1 +if [[ $# -eq 1 ]]; then + PROTO_DIR=$1 +else + PROTO_DIR=../protos fi +PROTO_DIR=$1 OUT_DIR=src/protos PATH=${PATH}:./node_modules/.bin @@ -18,12 +20,12 @@ grpc_tools_node_protoc \ --js_out=import_style=commonjs,binary:"${OUT_DIR}" \ --grpc_out=grpc_js:"${OUT_DIR}" \ --plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin \ - -I "$1" \ - "$1"/*.proto + -I "${PROTO_DIR}" \ + "${PROTO_DIR}"/*.proto # Generate TypeScript code (d.ts) for gRPC grpc_tools_node_protoc \ --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \ --ts_out=grpc_js:"${OUT_DIR}" \ - -I "$1" \ - "$1"/*.proto + -I "${PROTO_DIR}" \ + "${PROTO_DIR}"/*.proto diff --git a/docker/sorusora/Dockerfile b/sorusora/Dockerfile similarity index 100% rename from docker/sorusora/Dockerfile rename to sorusora/Dockerfile diff --git a/sorusora/build-protos.sh b/sorusora/build-protos.sh index 483f86b..760e1c3 100755 --- a/sorusora/build-protos.sh +++ b/sorusora/build-protos.sh @@ -1,8 +1,9 @@ #!/bin/bash -if [[ $# -ne 1 ]]; then - echo "Usage: $0 " - exit 1 +if [[ $# -eq 1 ]]; then + PROTO_DIR=$1 +else + PROTO_DIR=../protos fi OUT_DIR=protos @@ -20,7 +21,7 @@ fi ${EXEC} pip install grpcio-tools ${EXEC} python -m grpc_tools.protoc \ - -I "$1" \ + -I "${PROTO_DIR}" \ --python_out="${OUT_DIR}" \ --grpc_python_out="${OUT_DIR}" \ - "$1"/*.proto + "${PROTO_DIR}"/*.proto