diff --git a/airbyte-webapp/.gitignore b/airbyte-webapp/.gitignore index a00b2a3d5a3..a4963661feb 100644 --- a/airbyte-webapp/.gitignore +++ b/airbyte-webapp/.gitignore @@ -34,9 +34,6 @@ storybook-static/ # Generated by our build-info plugin /public/buildInfo.json -# Generated at build time -/public/docs - # Generated file to make the CDK version available in the webapp /src/components/connectorBuilder/cdk.ts diff --git a/airbyte-webapp/build.dockerfile b/airbyte-webapp/build.dockerfile deleted file mode 100644 index 8d70767280a..00000000000 --- a/airbyte-webapp/build.dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -ARG NODE_VERSION -FROM node:${NODE_VERSION}-slim AS base - -ENV PNPM_HOME=/pnpm -ENV PATH="$PNPM_HOME:$PATH" -ENV NPM_CONFIG_PREFIX=/pnpm -ARG PNPM_STORE_DIR=/pnpm/store -ARG PROJECT_DIR - -RUN apt update && apt install -y \ - curl \ - git \ - xxd \ - jq - -COPY . /workspace -WORKDIR ${PROJECT_DIR} - -RUN corepack enable && corepack install -RUN pnpm config set store-dir $PNPM_STORE_DIR - -FROM base AS build -RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile -RUN pnpm build - -FROM base AS common -COPY --from=build $PROJECT_DIR $PROJECT_DIR/build/app diff --git a/airbyte-webapp/build.gradle.kts b/airbyte-webapp/build.gradle.kts index 2e48aab58e1..d3e5d4a8ed8 100644 --- a/airbyte-webapp/build.gradle.kts +++ b/airbyte-webapp/build.gradle.kts @@ -10,6 +10,21 @@ plugins { alias(libs.plugins.node.gradle) } +/** + * Utility function to parse a .gitignore file into a list of ignore pattern entries + */ +fun parseIgnoreFile(f: File): List { + val ignores = mutableListOf() + f.forEachLine { line -> + //ignore comments and empty lines + if (!line.startsWith('#') && line.isNotEmpty()) { + ignores.add(line) + } + } + return ignores +} + + // Use the node version that's defined in the .nvmrc file val nodeVersion = file("${projectDir}/.nvmrc").readText().trim() @@ -18,17 +33,15 @@ val parsedJson = JsonSlurper().parse(FileReader("${projectDir}/package.json")) a val engines = parsedJson["engines"] as? Map<*, *> // Safely cast to Map if 'engines' exists val pnpmVer = engines?.get("pnpm")?.toString()?.trim() // Extract 'pnpm' as String and trim -/* -This array should contain a path to all configs that are common to most build tasks and -might affect them (i.e. if any of those files change we want to rerun most tasks) -*/ -val commonConfigs = listOf( - ".env", - ".env.production", - "package.json", - "pnpm-lock.yaml", - "tsconfig.json", - ".prettierrc.js" +/** + * A list of all files outside the webapp folder, that the webapp build depends on, i.e. + * if those change we can't reuse a cached build. + */ +val outsideWebappDependencies = listOf( + "../airbyte-api/src/main/openapi/config.yaml", + "../airbyte-api/src/main/openapi/cloud-config.yaml", + "../airbyte-connector-builder-server/src/main/openapi/openapi.yaml", + "../airbyte-connector-builder-resources/CDK_VERSION", ) configure { @@ -51,45 +64,35 @@ val nodeModules = fileTree("node_modules") { exclude(".cache") } -/* -fileTree to watch the public dir but exclude the auto generated buildInfo.json. It's content is anyway a -content hash, depending on the other files. -*/ -val publicDir = fileTree("public") { - exclude("buildInfo.json") +/** + * All files inside the webapp folder that aren't gitignored + */ +val allFiles = fileTree(".") { + exclude(parseIgnoreFile(file("../.gitignore"))) + exclude(parseIgnoreFile(file(".gitignore"))) + exclude(parseIgnoreFile(file("./src/core/api/generated/.gitignore"))) + exclude(parseIgnoreFile(file("./src/core/api/types/.gitignore"))) } tasks.register("pnpmBuild") { dependsOn(tasks.named("pnpmInstall")) - environment.put("VERSION", rootProject.ext.get("version") as String) args = listOf("build") + // The WEBAPP_BUILD_CLOUD_ENV environment variable is an input for this task, since it changes for which env we're building the webapp inputs.property("cloudEnv", System.getenv("WEBAPP_BUILD_CLOUD_ENV") ?: "") - inputs.files(commonConfigs) - inputs.files(nodeModules) - inputs.files(publicDir) - inputs.file(".eslintrc.js") - inputs.file(".stylelintrc") - inputs.file("orval.config.ts") - inputs.file("vite.config.mts") - inputs.file("index.html") - inputs.dir("scripts") - inputs.dir("src") + inputs.files(allFiles, outsideWebappDependencies) outputs.dir("build/app") } tasks.register("test") { - dependsOn(tasks.named("assemble")) - + dependsOn(tasks.named("pnpmInstall")) + args = listOf("run", "test:ci") - inputs.files(commonConfigs) - inputs.file("jest.config.ts") - inputs.file("babel.config.js") - inputs.dir("src") + inputs.files(allFiles, outsideWebappDependencies) /* The test has no outputs, thus we always treat the outputs up to date @@ -151,17 +154,12 @@ tasks.register("cloudE2eTest") { // } //} - tasks.register("buildStorybook") { dependsOn(tasks.named("pnpmInstall")) args = listOf("run", "build:storybook") - inputs.files(commonConfigs) - inputs.files(nodeModules) - inputs.files(publicDir) - inputs.dir(".storybook") - inputs.dir("src") + inputs.files(allFiles, outsideWebappDependencies) outputs.dir("build/storybook") diff --git a/airbyte-webapp/orval.config.ts b/airbyte-webapp/orval.config.ts index 5827f1efe60..fbacb429127 100644 --- a/airbyte-webapp/orval.config.ts +++ b/airbyte-webapp/orval.config.ts @@ -91,6 +91,7 @@ const createApi = (inputSpecFile: string, name: string, apiFn?: ApiFn, excludedP }; }; +// IMPORTANT: Whenever you change/add OpenAPI specs here, make sure to also adjust the outsideWebappDependencies list in build.gradle.kts export default defineConfig({ api: createApi("../airbyte-api/src/main/openapi/config.yaml", "AirbyteClient", "apiCall", [ // Required to exclude, due to us not being able to convert JSON parameters diff --git a/airbyte-webapp/release.dockerfile b/airbyte-webapp/release.dockerfile deleted file mode 100644 index 1470759e94b..00000000000 --- a/airbyte-webapp/release.dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -ARG BUILD_IMAGE -ARG NGINX_IMAGE=nginxinc/nginx-unprivileged:alpine3.18 - -FROM ${BUILD_IMAGE} AS builder - -FROM ${NGINX_IMAGE} - -EXPOSE 8080 - -ARG SRC_DIR=/workspace/oss/airbyte-webapp/build/app/build/app - -USER root -COPY --from=builder ${SRC_DIR} /usr/share/nginx/html -RUN find /usr/share/nginx/html -type d -exec chmod 755 '{}' \; -o -type f -exec chmod 644 '{}' \; -RUN chown -R nginx:nginx /usr/share/nginx/html -COPY nginx/default.conf.template /etc/nginx/templates/default.conf.template - -USER nginx:nginx diff --git a/deps.toml b/deps.toml index 382b2bfce4b..23d96cfb04b 100644 --- a/deps.toml +++ b/deps.toml @@ -260,6 +260,6 @@ temporal-telemetry = ["temporal-opentracing"] [plugins] ksp = { id ="com.google.devtools.ksp", version = "1.9.22-1.0.17"} -node-gradle = { id = "com.github.node-gradle.node", version = "7.0.1" } +node-gradle = { id = "com.github.node-gradle.node", version = "7.0.2" } nu-studer-jooq = { id = "nu.studer.jooq", version = "9.0" } de-undercouch-download = { id = "de.undercouch.download", version = "5.5.0" }