PromucFlow_constructor/scripts/prepare_server_artifacts.sh
Abhijeet 6ca9ef549e
feat: Make images adaptable to support both Postgres and MongoDB uris (#36424)
## Description
PR to make the release tag adaptable to work with both MongoDB and
PostgreSQL uris.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new script to automate the preparation of server
artifacts, improving the build process.
- Added SQL files to the indentation configuration for consistent code
formatting.

- **Improvements**
- Enhanced error handling in the Docker build process to ensure
essential files are present before execution.
- Updated service configuration logic to prevent misconfiguration based
on the environment.
- Added a new job step in the build workflow to prepare server artifacts
after the build process.
- Implemented conditional logic in the run script to dynamically adapt
to different database configurations.

- **Bug Fixes**
- Adjusted the initialization process to focus on MongoDB, improving
reliability in various environments.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

/test Sanity

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/10940528231>
> Commit: 32731e8a93a25e5c9456eb89daca2d8bf327c012
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10940528231&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Thu, 19 Sep 2024 12:21:54 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No
2024-09-19 21:45:46 +05:30

28 lines
834 B
Bash
Executable File

#!/bin/bash -eux
cd "$(git rev-parse --show-toplevel)"
if [[ -z "${EDITION-}" ]]; then
export EDITION=ce
if [[ "$(git remote get-url origin)" == *appsmithorg/appsmith-ee* ]]; then
export EDITION=ee
fi
fi
PG_TAG="${PG_TAG-pg}"
echo "Will be copying pg server artifacts from appsmith-$EDITION:$PG_TAG"
target="deploy/docker/fs/opt/appsmith/server"
mkdir -p "$target"
rm -rf "$target"/{pg,mongo}
cp -r "app/server/dist" "$target/mongo"
mv "$target/mongo"/server-*.jar "$target/mongo/server.jar"
# Grab PostgreSQL server artifacts from Docker image.
image="appsmith/appsmith-$EDITION:$PG_TAG"
docker run --name xx --detach --entrypoint sleep "$image" infinity
docker cp xx:/opt/appsmith/server/pg "$target/pg"
docker cp xx:/opt/appsmith/info.json "$target/pg/source-info.json"
docker rm --force xx
docker image rm "$image"