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
This commit is contained in:
parent
c76e6c031c
commit
6ca9ef549e
|
|
@ -9,5 +9,5 @@ indent_size = 2
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
[{*.java,pom.xml,*.py}]
|
[{*.java,pom.xml,*.py,*.sql}]
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
|
||||||
6
.github/workflows/build-docker-image.yml
vendored
6
.github/workflows/build-docker-image.yml
vendored
|
|
@ -79,6 +79,12 @@ jobs:
|
||||||
if [[ -f scripts/generate_info_json.sh ]]; then
|
if [[ -f scripts/generate_info_json.sh ]]; then
|
||||||
scripts/generate_info_json.sh
|
scripts/generate_info_json.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Place server artifacts-es
|
||||||
|
env:
|
||||||
|
EDITION: ${{ vars.EDITION }}
|
||||||
|
run: |
|
||||||
|
scripts/prepare_server_artifacts.sh
|
||||||
|
|
||||||
- name: Set base image tag
|
- name: Set base image tag
|
||||||
id: set_base_tag
|
id: set_base_tag
|
||||||
|
|
|
||||||
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -5,6 +5,9 @@
|
||||||
stacks
|
stacks
|
||||||
/deploy/docker/fs/opt/appsmith/info.json
|
/deploy/docker/fs/opt/appsmith/info.json
|
||||||
|
|
||||||
|
# Server artifacts
|
||||||
|
/deploy/docker/fs/opt/appsmith/server
|
||||||
|
|
||||||
# to ignore the node_modeules folder
|
# to ignore the node_modeules folder
|
||||||
node_modules
|
node_modules
|
||||||
# to ignore the package-lock.json file
|
# to ignore the package-lock.json file
|
||||||
|
|
@ -36,3 +39,5 @@ app/client/.fleet/*
|
||||||
# Observability related local storage
|
# Observability related local storage
|
||||||
utils/observability/tempo-data/*
|
utils/observability/tempo-data/*
|
||||||
|
|
||||||
|
# Ignore the mongo data backup directory for Mongo to PG migrations
|
||||||
|
mongo-data**
|
||||||
20
Dockerfile
20
Dockerfile
|
|
@ -3,10 +3,6 @@ FROM ${BASE}
|
||||||
|
|
||||||
ENV IN_DOCKER=1
|
ENV IN_DOCKER=1
|
||||||
|
|
||||||
# Add backend server - Application Layer
|
|
||||||
ARG JAR_FILE=./app/server/dist/server-*.jar
|
|
||||||
ARG PLUGIN_JARS=./app/server/dist/plugins/*.jar
|
|
||||||
|
|
||||||
ARG APPSMITH_CLOUD_SERVICES_BASE_URL
|
ARG APPSMITH_CLOUD_SERVICES_BASE_URL
|
||||||
ENV APPSMITH_CLOUD_SERVICES_BASE_URL=${APPSMITH_CLOUD_SERVICES_BASE_URL}
|
ENV APPSMITH_CLOUD_SERVICES_BASE_URL=${APPSMITH_CLOUD_SERVICES_BASE_URL}
|
||||||
|
|
||||||
|
|
@ -16,7 +12,17 @@ ENV APPSMITH_SEGMENT_CE_KEY=${APPSMITH_SEGMENT_CE_KEY}
|
||||||
COPY deploy/docker/fs /
|
COPY deploy/docker/fs /
|
||||||
|
|
||||||
RUN <<END
|
RUN <<END
|
||||||
mkdir -p ./editor ./rts ./backend/plugins
|
if ! [ -f info.json ]; then
|
||||||
|
echo "Missing info.json" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [ -f server/mongo/server.jar && -f server/pg/server.jar ]; then
|
||||||
|
echo "Missing one or both server.jar files in the right place. Are you using the build script?" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p ./editor ./rts
|
||||||
|
|
||||||
# Ensure all *.sh scripts are executable.
|
# Ensure all *.sh scripts are executable.
|
||||||
find . -name node_modules -prune -or -type f -name '*.sh' -print -exec chmod +x '{}' ';'
|
find . -name node_modules -prune -or -type f -name '*.sh' -print -exec chmod +x '{}' ';'
|
||||||
|
|
@ -25,10 +31,6 @@ RUN <<END
|
||||||
chmod +x /opt/bin/*
|
chmod +x /opt/bin/*
|
||||||
END
|
END
|
||||||
|
|
||||||
#Add the jar to the container
|
|
||||||
COPY ${JAR_FILE} backend/server.jar
|
|
||||||
COPY ${PLUGIN_JARS} backend/plugins/
|
|
||||||
|
|
||||||
# Add client UI - Application Layer
|
# Add client UI - Application Layer
|
||||||
COPY ./app/client/build editor/
|
COPY ./app/client/build editor/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -372,7 +372,7 @@ configure_supervisord() {
|
||||||
|
|
||||||
# Disable services based on configuration
|
# Disable services based on configuration
|
||||||
if [[ -z "${DYNO}" ]]; then
|
if [[ -z "${DYNO}" ]]; then
|
||||||
if [[ $isUriLocal -eq 0 ]]; then
|
if [[ $isUriLocal -eq 0 && $isMongoUrl -eq 1 ]]; then
|
||||||
cp "$supervisord_conf_source/mongodb.conf" "$SUPERVISORD_CONF_TARGET"
|
cp "$supervisord_conf_source/mongodb.conf" "$SUPERVISORD_CONF_TARGET"
|
||||||
fi
|
fi
|
||||||
if [[ $APPSMITH_REDIS_URL == *"localhost"* || $APPSMITH_REDIS_URL == *"127.0.0.1"* ]]; then
|
if [[ $APPSMITH_REDIS_URL == *"localhost"* || $APPSMITH_REDIS_URL == *"127.0.0.1"* ]]; then
|
||||||
|
|
@ -508,9 +508,6 @@ if [[ -z "${DYNO}" ]]; then
|
||||||
tlog "Initializing MongoDB"
|
tlog "Initializing MongoDB"
|
||||||
init_mongodb
|
init_mongodb
|
||||||
init_replica_set
|
init_replica_set
|
||||||
elif [[ $isPostgresUrl -eq 1 ]]; then
|
|
||||||
tlog "Initializing Postgres"
|
|
||||||
# init_postgres
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# These functions are used to limit heap size for Backend process when deployed on Heroku
|
# These functions are used to limit heap size for Backend process when deployed on Heroku
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,14 @@ set -o pipefail
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o noglob
|
set -o noglob
|
||||||
|
|
||||||
|
mode=mongo
|
||||||
|
if [[ "$APPSMITH_DB_URL" = postgresql://* ]]; then
|
||||||
|
mode=pg
|
||||||
|
fi
|
||||||
|
|
||||||
|
tlog "Running with $mode."
|
||||||
|
cd "/opt/appsmith/server/$mode"
|
||||||
|
|
||||||
declare -a extra_args
|
declare -a extra_args
|
||||||
proxy_configured=0
|
proxy_configured=0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
[program:backend]
|
[program:backend]
|
||||||
directory=/opt/appsmith/backend
|
|
||||||
command=/opt/appsmith/run-with-env.sh /opt/appsmith/run-java.sh
|
command=/opt/appsmith/run-with-env.sh /opt/appsmith/run-java.sh
|
||||||
priority=20
|
priority=20
|
||||||
autostart=true
|
autostart=true
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,10 @@ if ! ./build.sh -DskipTests > /dev/null; then
|
||||||
echo Server build failed >&2
|
echo Server build failed >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
popd
|
||||||
|
./scripts/prepare_server_artifacts.sh
|
||||||
pretty_print "Server build successful. Starting client build ..."
|
pretty_print "Server build successful. Starting client build ..."
|
||||||
|
|
||||||
popd
|
|
||||||
pushd app/client > /dev/null
|
pushd app/client > /dev/null
|
||||||
yarn > /dev/null
|
yarn > /dev/null
|
||||||
if ! yarn build > /dev/null; then
|
if ! yarn build > /dev/null; then
|
||||||
|
|
|
||||||
28
scripts/prepare_server_artifacts.sh
Executable file
28
scripts/prepare_server_artifacts.sh
Executable file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/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"
|
||||||
Loading…
Reference in New Issue
Block a user