Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom auto-setup temporal docker image #7681

Merged
merged 71 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
0f06d95
Remove the use of docker compose to build
benmoriceau Oct 29, 2021
e85f1a9
Update .dockerignore
benmoriceau Oct 29, 2021
dbbb298
Add explicit dependencies
benmoriceau Oct 29, 2021
9b00dc5
Allign .dockerfileingnore, rm implicit dependencies
benmoriceau Oct 29, 2021
0f049e7
improve scheduler gradle
benmoriceau Nov 1, 2021
8957cd7
Clean up migration gradle file
benmoriceau Nov 1, 2021
e3dd246
Clean up server gradle
benmoriceau Nov 1, 2021
8f83ea8
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/rem…
benmoriceau Nov 1, 2021
5ab190c
tmp
benmoriceau Nov 1, 2021
7d32b90
Look at diff
benmoriceau Nov 1, 2021
d693c5c
rm unwanted files
benmoriceau Nov 1, 2021
8084031
Make sure that we don't commit file that will be copied to the docker…
benmoriceau Nov 1, 2021
e63c0f2
Make the scheduler docker build to be increamental
benmoriceau Nov 1, 2021
1b6bc9b
Make the worker docker build to be incremental
benmoriceau Nov 1, 2021
3b9efe9
make a the server docker build to be incremental
benmoriceau Nov 1, 2021
5b3f566
Make the airbyte-migration to be incremental
benmoriceau Nov 1, 2021
dee7b07
Make the webapp docker build incremental
benmoriceau Nov 1, 2021
2976178
Make the config init docker build to be incremental
benmoriceau Nov 1, 2021
cb538db
Remove the dockerignorfile
benmoriceau Nov 1, 2021
fecb366
remove unused gradle block
benmoriceau Nov 1, 2021
71e79da
Make the airbyte cli docker build incremental
benmoriceau Nov 1, 2021
24a7cf8
Rm the use of composeBuild
benmoriceau Nov 1, 2021
c9251d9
Fix cli docker image name
benmoriceau Nov 2, 2021
d12c485
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/rem…
benmoriceau Nov 2, 2021
07d67f6
Fix migration build
benmoriceau Nov 2, 2021
b8bbbab
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/rem…
benmoriceau Nov 2, 2021
23ed511
Use the same version than prod
benmoriceau Nov 2, 2021
3acd34e
Add missing version update in the airbyte scheduler
benmoriceau Nov 2, 2021
d279ca2
Move all the docker build related files to the build folder
benmoriceau Nov 2, 2021
b32056c
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/rem…
benmoriceau Nov 2, 2021
d53150c
Remove outdated file updates
benmoriceau Nov 2, 2021
0c47eb7
Fix workers project
benmoriceau Nov 2, 2021
014a29a
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/rem…
benmoriceau Nov 2, 2021
cba2bce
update config docker build
benmoriceau Nov 2, 2021
fa899f9
Pr comments and factorization example
benmoriceau Nov 2, 2021
43bb8b0
Single definition of the incremental docker tasks
benmoriceau Nov 3, 2021
a52643f
Add documentation
benmoriceau Nov 3, 2021
b0ae593
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/rem…
benmoriceau Nov 3, 2021
8a3b1fc
test
benmoriceau Nov 3, 2021
317ae87
Make the factorize incremental to work
benmoriceau Nov 3, 2021
86b22b2
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/rem…
benmoriceau Nov 3, 2021
d64750a
Update docs and remove unused import
benmoriceau Nov 3, 2021
d42857a
Fix build and remove unused pluggins
benmoriceau Nov 3, 2021
24fd33c
Update doc based on PR comments
benmoriceau Nov 4, 2021
2bf9b18
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/rem…
benmoriceau Nov 4, 2021
af63336
Make 2 seperate docker compose task for temporal
benmoriceau Nov 5, 2021
5f3e59d
Auto update the temporal DB upon start
benmoriceau Nov 5, 2021
3cd260c
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/tem…
benmoriceau Nov 5, 2021
cc873f1
rename to temporal
benmoriceau Nov 5, 2021
f555334
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/tem…
benmoriceau Nov 5, 2021
c6b488c
Add generated file
benmoriceau Nov 5, 2021
8768e38
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/tem…
benmoriceau Nov 8, 2021
6f3b1f3
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/tem…
benmoriceau Nov 9, 2021
a94f912
tmp
benmoriceau Nov 9, 2021
57dbc40
tmp
benmoriceau Nov 9, 2021
c218c23
Tmp
benmoriceau Nov 10, 2021
11adb75
Tmp
benmoriceau Nov 10, 2021
528ef60
Tmp
benmoriceau Nov 10, 2021
63bd053
update script
benmoriceau Nov 10, 2021
48db2f5
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/tem…
benmoriceau Nov 10, 2021
9a77dec
update script
benmoriceau Nov 10, 2021
aadaa4f
Fix docker-compose down
benmoriceau Nov 10, 2021
57c7f83
Finalize script
benmoriceau Nov 10, 2021
ddc3197
PR comments
benmoriceau Nov 10, 2021
d88110a
add temporal to the generate-docker task
benmoriceau Nov 10, 2021
142d30c
Wait before killing the process
benmoriceau Nov 10, 2021
686f248
get rid of timeout
benmoriceau Nov 10, 2021
e15f8fc
use docker-compose down
benmoriceau Nov 10, 2021
ae45d3c
Fix compose down
benmoriceau Nov 10, 2021
6791ad6
Update doc
benmoriceau Nov 10, 2021
2400b1e
Merge branch 'master' into bmoric/temporal-possible-migration
benmoriceau Nov 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions airbyte-temporal/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# A test describe in the README is available to test a version update
FROM temporalio/auto-setup:1.13.0

ENV TEMPORAL_HOME /etc/temporal

COPY bin/scripts/update-and-start-temporal.sh update-and-start-temporal.sh

ENTRYPOINT ["./update-and-start-temporal.sh"]
14 changes: 14 additions & 0 deletions airbyte-temporal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Testing a temporal migration

`tools/bin/test_temporal_migration.sh` is available to test that a bump of the temporal version won't break the docker compose build. Here is what
the script does:
- checkout master
- build the docker image
- run docker compose up in the background
- Sleep for 75 secondes
- shutdown docker compose
- checkout the commit being tested
- build the docker image
- run docker compose up.

At the end of the script you should be able to access a local airbyte in `localhost:8000`.
10 changes: 10 additions & 0 deletions airbyte-temporal/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
task copyScripts(type: Copy) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you're copying this as opposed to just defining the update-and-start-temporal.sh in the docker/scripts directory? It's not a build artifact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docker build task will copy the dockerfile to the build/docker folder so I need to copy the script in this folder too.

dependsOn copyDocker

from('scripts')
into 'build/docker/bin/scripts'
}

Task dockerBuildTask = getDockerBuildTask("temporal", "$project.projectDir")
dockerBuildTask.dependsOn(copyScripts)
assemble.dependsOn(dockerBuildTask)
136 changes: 136 additions & 0 deletions airbyte-temporal/scripts/update-and-start-temporal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#!/usr/bin/env bash

set -x

DBNAME="${DBNAME:-temporal}"
VISIBILITY_DBNAME="${VISIBILITY_DBNAME:-temporal_visibility}"
DB_PORT="${DB_PORT:-3306}"

POSTGRES_SEEDS="${POSTGRES_SEEDS:-}"
POSTGRES_USER="${POSTGRES_USER:-}"
POSTGRES_PWD="${POSTGRES_PWD:-}"

SCHEMA_DIR=${TEMPORAL_HOME}/schema/postgresql/v96/temporal/versioned
VISIBILITY_SCHEMA_DIR=${TEMPORAL_HOME}/schema/postgresql/v96/visibility/versioned

SKIP_DEFAULT_NAMESPACE_CREATION="${SKIP_DEFAULT_NAMESPACE_CREATION:-false}"
DEFAULT_NAMESPACE="${DEFAULT_NAMESPACE:-default}"
DEFAULT_NAMESPACE_RETENTION=${DEFAULT_NAMESPACE_RETENTION:-1}

# See https://github.com/temporalio/temporal/blob/release/v1.13.x/docker/entrypoint.sh
init_entry_point() {
echo "Start init"
export BIND_ON_IP="${BIND_ON_IP:-$(hostname -i)}"

if [[ "${BIND_ON_IP}" =~ ":" ]]; then
# ipv6
export TEMPORAL_CLI_ADDRESS="[${BIND_ON_IP}]:7233"
else
# ipv4
export TEMPORAL_CLI_ADDRESS="${BIND_ON_IP}:7233"
fi

dockerize -template ./config/config_template.yaml:./config/docker.yaml
echo "Done init"
}

wait_for_postgres() {
until nc -z "${POSTGRES_SEEDS%%,*}" "${DB_PORT}"; do
echo 'Waiting for PostgreSQL to startup.'
sleep 1
done

echo 'PostgreSQL started.'
}

update_postgres_schema() {
{ export SQL_PASSWORD=${POSTGRES_PWD}; } 2> /dev/null

CONTAINER_ALREADY_STARTED="CONTAINER_ALREADY_STARTED_PLACEHOLDER"
if [ ! -e $CONTAINER_ALREADY_STARTED ]; then
touch $CONTAINER_ALREADY_STARTED
temporal-sql-tool --plugin postgres --ep "${POSTGRES_SEEDS}" -u "${POSTGRES_USER}" -p "${DB_PORT}" create --db "${DBNAME}"
temporal-sql-tool --plugin postgres --ep "${POSTGRES_SEEDS}" -u "${POSTGRES_USER}" -p "${DB_PORT}" --db "${DBNAME}" setup-schema -v 0.0


temporal-sql-tool --plugin postgres --ep "${POSTGRES_SEEDS}" -u "${POSTGRES_USER}" -p "${DB_PORT}" create --db "${VISIBILITY_DBNAME}"
temporal-sql-tool --plugin postgres --ep "${POSTGRES_SEEDS}" -u "${POSTGRES_USER}" -p "${DB_PORT}" --db "${VISIBILITY_DBNAME}" setup-schema -v 0.0
fi
echo "Starting to update the temporal DB"
temporal-sql-tool --plugin postgres --ep "${POSTGRES_SEEDS}" -u "${POSTGRES_USER}" -p "${DB_PORT}" --db "${DBNAME}" update-schema -d "${SCHEMA_DIR}"
echo "Update the temporal DB is done"

echo "Starting to update the temporal visibility DB"
temporal-sql-tool --plugin postgres --ep "${POSTGRES_SEEDS}" -u "${POSTGRES_USER}" -p "${DB_PORT}" --db "${VISIBILITY_DBNAME}" update-schema -d "${VISIBILITY_SCHEMA_DIR}"
echo "Update the temporal visibility DB is done"

}

setup_server(){
echo "Temporal CLI address: ${TEMPORAL_CLI_ADDRESS}."

until tctl cluster health | grep SERVING; do
echo "Waiting for Temporal server to start..."
sleep 1
done
echo "Temporal server started."

if [ "${SKIP_DEFAULT_NAMESPACE_CREATION}" != true ]; then
register_default_namespace
fi

if [ "${SKIP_ADD_CUSTOM_SEARCH_ATTRIBUTES}" != true ]; then
add_custom_search_attributes
fi
}
register_default_namespace() {
echo "Registering default namespace: ${DEFAULT_NAMESPACE}."
if ! tctl --ns "${DEFAULT_NAMESPACE}" namespace describe; then
echo "Default namespace ${DEFAULT_NAMESPACE} not found. Creating..."
tctl --ns "${DEFAULT_NAMESPACE}" namespace register --rd "${DEFAULT_NAMESPACE_RETENTION}" --desc "Default namespace for Temporal Server."
echo "Default namespace ${DEFAULT_NAMESPACE} registration complete."
else
echo "Default namespace ${DEFAULT_NAMESPACE} already registered."
fi
}

add_custom_search_attributes() {
echo "Adding Custom*Field search attributes."
# TODO: Remove CustomStringField
# @@@SNIPSTART add-custom-search-attributes-for-testing-command
tctl --auto_confirm admin cluster add-search-attributes \
--name CustomKeywordField --type Keyword \
--name CustomStringField --type Text \
--name CustomTextField --type Text \
--name CustomIntField --type Int \
--name CustomDatetimeField --type Datetime \
--name CustomDoubleField --type Double \
--name CustomBoolField --type Bool
# @@@SNIPEND
}

setup_server(){
echo "Temporal CLI address: ${TEMPORAL_CLI_ADDRESS}."

until tctl cluster health | grep SERVING; do
echo "Waiting for Temporal server to start..."
sleep 1
done
echo "Temporal server started."

if [ "${SKIP_DEFAULT_NAMESPACE_CREATION}" != true ]; then
register_default_namespace
fi

if [ "${SKIP_ADD_CUSTOM_SEARCH_ATTRIBUTES}" != true ]; then
add_custom_search_attributes
fi
}

init_entry_point
wait_for_postgres
update_postgres_schema

echo "starting temporal server"
setup_server &
./start-temporal.sh
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ task('generate-docker') {
dependsOn(':airbyte-migration:assemble')
dependsOn(':airbyte-db:lib:assemble')
dependsOn(':airbyte-config:init:assemble')
dependsOn(':airbyte-temporal:assemble')
}

// produce reproducible archives
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
ports:
- 8011:5432
airbyte-temporal-ui:
image: temporalio/web:latest
image: temporalio/web:1.13.0
logging: *default-logging
container_name: airbyte-temporal-ui
restart: unless-stopped
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ services:
- OPENREPLAY=${OPENREPLAY:-}
- PAPERCUPS_STORYTIME=${PAPERCUPS_STORYTIME:-}
airbyte-temporal:
image: temporalio/auto-setup:1.7.0
image: airbyte/temporal:${VERSION}
logging: *default-logging
container_name: airbyte-temporal
restart: unless-stopped
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ if (!System.getenv().containsKey("SUB_BUILD") || System.getenv().get("SUB_BUILD"
include ':airbyte-scheduler:app'
include ':airbyte-scheduler:client'
include ':airbyte-server'
include 'airbyte-temporal'
include ':airbyte-tests'
include ':airbyte-webapp'
include ':airbyte-config:init'
Expand Down
30 changes: 30 additions & 0 deletions tools/bin/test-temporal-migration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#! /bin/bash

set -ex

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

if ! command -v timeout &> /dev/null
then
echo "timeout could not be found, installing it"
brew install coreutils
fi

NEW_HASH="$( git rev-parse HEAD )"

git checkout master
git pull --no-rebase

SUB_BUILD=PLATFORM "$SCRIPT_DIR"/../../gradlew -p "$SCRIPT_DIR"/../.. generate-docker

cd "$SCRIPT_DIR"/../..
VERSION=dev docker-compose -f "$SCRIPT_DIR"/../../docker-compose.yaml up &

sleep 75
VERSION=dev docker-compose down

git stash
git checkout $NEW_HASH
SUB_BUILD=PLATFORM "$SCRIPT_DIR"/../../gradlew -p "$SCRIPT_DIR"/../.. generate-docker

VERSION=dev docker-compose -f "$SCRIPT_DIR"/../../docker-compose.yaml up