Skip to content

Commit

Permalink
Revert "Bmoric/remove docker compose for build (airbytehq#7500)" (air…
Browse files Browse the repository at this point in the history
…bytehq#7698)

This reverts commit 4e17fa2.
  • Loading branch information
benmoriceau authored and schlattk committed Jan 4, 2022
1 parent 386ea10 commit 554e508
Show file tree
Hide file tree
Showing 30 changed files with 77 additions and 194 deletions.
2 changes: 0 additions & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ serialize =

[bumpversion:file:.env]

[bumpversion:file:airbyte-migration/Dockerfile]

[bumpversion:file:airbyte-server/Dockerfile]

[bumpversion:file:airbyte-workers/Dockerfile]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ jobs:
EOF
- name: Build Platform Docker Images
run: SUB_BUILD=PLATFORM ./gradlew --no-daemon assemble --scan
run: SUB_BUILD=PLATFORM ./gradlew --no-daemon composebuild --scan

- name: Run End-to-End Frontend Tests
run: ./tools/bin/e2e_test.sh
Expand Down Expand Up @@ -457,7 +457,7 @@ jobs:
HOME: /home/runner

- name: Build Platform Docker Images
run: SUB_BUILD=PLATFORM ./gradlew assemble --scan
run: SUB_BUILD=PLATFORM ./gradlew composeBuild --scan

- name: Run Kubernetes End-to-End Acceptance Tests
env:
Expand Down
6 changes: 3 additions & 3 deletions airbyte-cli/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Task dockerBuildTask = getDockerBuildTask("cli", "$project.projectDir")
dockerBuildTask.dependsOn(copyDocker)
assemble.dependsOn(dockerBuildTask)
plugins {
id "airbyte-docker"
}
3 changes: 3 additions & 0 deletions airbyte-config/init/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!src
!scripts
2 changes: 1 addition & 1 deletion airbyte-config/init/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ WORKDIR /app

# the sole purpose of this image is to seed the data volume with the default data
# that the app should have when it is first installed.
COPY bin/scripts scripts
COPY scripts scripts
11 changes: 0 additions & 11 deletions airbyte-config/init/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,3 @@ dependencies {
implementation project(':airbyte-commons-docker')
implementation project(':airbyte-json-validation')
}

task copyScripts(type: Copy) {
dependsOn copyDocker

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

Task dockerBuildTask = getDockerBuildTask("init", "$project.projectDir")
dockerBuildTask.dependsOn(copyScripts)
assemble.dependsOn(dockerBuildTask)
2 changes: 2 additions & 0 deletions airbyte-db/lib/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!src
2 changes: 1 addition & 1 deletion airbyte-db/lib/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM postgres:13-alpine

COPY bin/init.sql /docker-entrypoint-initdb.d/000_init.sql
COPY src/main/resources/init.sql /docker-entrypoint-initdb.d/000_init.sql
13 changes: 0 additions & 13 deletions airbyte-db/lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,3 @@ task(dumpJobsSchema, dependsOn: 'classes', type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath
args 'jobs', 'dump_schema'
}

task copyInitSql(type: Copy) {
dependsOn copyDocker

from('src/main/resources') {
include 'init.sql'
}
into 'build/docker/bin'
}

Task dockerBuildTask = getDockerBuildTask("db", "$project.projectDir")
dockerBuildTask.dependsOn(copyInitSql)
assemble.dependsOn(dockerBuildTask)
3 changes: 3 additions & 0 deletions airbyte-migration/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!Dockerfile
!build
2 changes: 1 addition & 1 deletion airbyte-migration/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV APPLICATION airbyte-migration
WORKDIR /app

# Move and run scheduler
COPY bin/${APPLICATION}-0.30.31-alpha.tar ${APPLICATION}.tar
COPY build/distributions/${APPLICATION}*.tar ${APPLICATION}.tar

RUN tar xf ${APPLICATION}.tar --strip-components=1

Expand Down
13 changes: 0 additions & 13 deletions airbyte-migration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,3 @@ application {
mainClass = 'io.airbyte.migrate.MigrationRunner'
}

task copyGeneratedTar(type: Copy) {
dependsOn distTar
dependsOn copyDocker

from('build/distributions') {
include 'airbyte-migration-*.tar'
}
into 'build/docker/bin'
}

Task dockerBuildTask = getDockerBuildTask("migration", "$project.projectDir")
dockerBuildTask.dependsOn(copyGeneratedTar)
assemble.dependsOn(dockerBuildTask)
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.function.Function;
import java.util.function.Supplier;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.http.client.utils.URIBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
3 changes: 3 additions & 0 deletions airbyte-scheduler/app/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!Dockerfile
!build
2 changes: 1 addition & 1 deletion airbyte-scheduler/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV APPLICATION airbyte-scheduler

WORKDIR /app

ADD bin/${APPLICATION}-0.30.31-alpha.tar /app
ADD build/distributions/${APPLICATION}-0.30.31-alpha.tar /app

# wait for upstream dependencies to become available before starting server
ENTRYPOINT ["/bin/bash", "-c", "${APPLICATION}-0.30.31-alpha/bin/${APPLICATION}"]
14 changes: 0 additions & 14 deletions airbyte-scheduler/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,3 @@ run {
environment "TEMPORAL_HOST", "localhost:7233"

}

task copyGeneratedTar(type: Copy) {
dependsOn copyDocker
dependsOn distTar

from('build/distributions') {
include 'airbyte-scheduler-*.tar'
}
into 'build/docker/bin'
}

Task dockerBuildTask = getDockerBuildTask("scheduler", "$project.projectDir")
dockerBuildTask.dependsOn(copyGeneratedTar)
assemble.dependsOn(dockerBuildTask)
3 changes: 3 additions & 0 deletions airbyte-server/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!Dockerfile
!build
2 changes: 1 addition & 1 deletion airbyte-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV APPLICATION airbyte-server

WORKDIR /app

ADD bin/${APPLICATION}-0.30.31-alpha.tar /app
ADD build/distributions/${APPLICATION}-0.30.31-alpha.tar /app

# wait for upstream dependencies to become available before starting server
ENTRYPOINT ["/bin/bash", "-c", "${APPLICATION}-0.30.31-alpha/bin/${APPLICATION}"]
14 changes: 0 additions & 14 deletions airbyte-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,3 @@ run {
environment "AIRBYTE_ROLE", System.getenv('AIRBYTE_ROLE')
environment "TEMPORAL_HOST", "localhost:7233"
}

task copyGeneratedTar(type: Copy) {
dependsOn copyDocker
dependsOn distTar

from('build/distributions') {
include 'airbyte-server-*.tar'
}
into 'build/docker/bin'
}

Task dockerBuildTask = getDockerBuildTask("server", "$project.projectDir")
dockerBuildTask.dependsOn(copyGeneratedTar)
assemble.dependsOn(dockerBuildTask)
4 changes: 4 additions & 0 deletions airbyte-webapp/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!Dockerfile
!build
!nginx
8 changes: 5 additions & 3 deletions airbyte-webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ FROM nginx:1.19-alpine as webapp

EXPOSE 80

COPY bin/docs docs/
COPY bin/build /usr/share/nginx/html
COPY bin/nginx/default.conf.template /etc/nginx/templates/default.conf.template
COPY build/docs docs/
# docs get copied twice because npm gradle plugin ignores output dir.
COPY build /usr/share/nginx/html
RUN rm -rf /usr/share/nginx/html/docs
COPY nginx/default.conf.template /etc/nginx/templates/default.conf.template
31 changes: 2 additions & 29 deletions airbyte-webapp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,11 @@ task test(type: NpmTask) {
assemble.dependsOn npm_run_build
build.finalizedBy test

task copyBuild(type: Copy) {
dependsOn copyDocker

from "${project.projectDir}/build"
into "build/docker/bin/build"
exclude ".docker"
exclude "docker"
}

task copyDocs(type: Copy) {
dependsOn copyDocker

from "${project.rootProject.projectDir}/docs/integrations"
into "build/docker/bin/docs/integrations"
from "${System.getProperty("user.dir")}/docs/integrations"
into "${buildDir}/docs/integrations"
duplicatesStrategy DuplicatesStrategy.INCLUDE
}

task copyNginx(type: Copy) {
dependsOn copyDocker

from "${project.projectDir}/nginx"
into "build/docker/bin/nginx"
}

copyBuild.dependsOn npm_run_build
copyNginx.dependsOn npm_run_build
copyDocs.dependsOn npm_run_build
assemble.dependsOn copyDocs
copyDocker.dependsOn(npm_run_build)

Task dockerBuildTask = getDockerBuildTask("webapp", "$project.projectDir")
dockerBuildTask.dependsOn(copyBuild)
dockerBuildTask.dependsOn(copyNginx)
dockerBuildTask.dependsOn(copyDocs)
assemble.dependsOn(dockerBuildTask)
2 changes: 1 addition & 1 deletion airbyte-workers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ENV APPLICATION airbyte-workers
WORKDIR /app

# Move worker app
ADD bin/${APPLICATION}-0.30.31-alpha.tar /app
ADD build/distributions/${APPLICATION}-0.30.31-alpha.tar /app

# wait for upstream dependencies to become available before starting server
ENTRYPOINT ["/bin/bash", "-c", "${APPLICATION}-0.30.31-alpha/bin/${APPLICATION}"]
14 changes: 0 additions & 14 deletions airbyte-workers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,3 @@ application {
mainClass = mainClassName
applicationDefaultJvmArgs = ['-XX:MaxRAMPercentage=75.0']
}

task copyGeneratedTar(type: Copy) {
dependsOn copyDocker
dependsOn distTar

from('build/distributions') {
include 'airbyte-workers-*.tar'
}
into 'build/docker/bin'
}

Task dockerBuildTask = getDockerBuildTask("worker", "$project.projectDir")
dockerBuildTask.dependsOn(copyGeneratedTar)
assemble.dependsOn(dockerBuildTask)
59 changes: 37 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage

buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:7.1.0'
}
}

plugins {
id 'base'
id 'pmd'
Expand Down Expand Up @@ -146,19 +133,26 @@ def Task getDockerBuildTask(String artifactName, String projectDir) {
}

allprojects {
apply plugin: 'com.bmuschko.docker-remote-api'

task copyDocker(type: Copy) {
delete "build/docker"
apply plugin: 'base'

from "${project.projectDir}/Dockerfile"
into "build/docker/"
afterEvaluate { project ->
def composeDeps = [
":airbyte-config:init",
":airbyte-db:lib",
":airbyte-migration",
":airbyte-scheduler:app",
":airbyte-workers",
":airbyte-server",
":airbyte-webapp",
].toSet().asImmutable()

if (project.getPath() in composeDeps) {
composeBuild.dependsOn(project.getPath() + ':assemble')
}
}
}

allprojects {
apply plugin: 'base'

// by default gradle uses directory as the project name. That works very well in a single project environment but
// projects clobber each other in an environments with subprojects when projects are in directories named identically.
def sub = rootDir.relativePath(projectDir.parentFile).replace('/', '.')
Expand Down Expand Up @@ -260,7 +254,6 @@ subprojects {
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.2'
testImplementation 'org.mockito:mockito-junit-jupiter:3.12.4'
testImplementation 'org.assertj:assertj-core:3.21.0'

}

tasks.withType(Tar) {
Expand All @@ -272,6 +265,28 @@ subprojects {
}
}

task composeBuild {
def buildTag = System.getenv('VERSION') ?: 'dev'
def buildPlatform = System.getenv('DOCKER_BUILD_PLATFORM') ?: 'linux/amd64'
def buildArch = System.getenv('DOCKER_BUILD_ARCH') ?: 'amd64'
def jdkVersion = System.getenv('JDK_VERSION') ?: '14.0.2'
def dockerComposeFile = buildArch == 'arm64' ? 'docker-compose.build-m1.yaml' : 'docker-compose.build.yaml'
doFirst {
exec {
workingDir rootDir
commandLine 'docker-compose', '-f', dockerComposeFile, 'build', '--parallel', '--quiet'
environment 'VERSION', buildTag
environment 'DOCKER_BUILD_PLATFORM', buildPlatform
environment 'DOCKER_BUILD_ARCH', buildArch
environment 'JDK_VERSION', jdkVersion
}
}
}

if (!System.getenv().containsKey("SUB_BUILD") || System.getenv().get("SUB_BUILD") == "PLATFORM") {
build.dependsOn(composeBuild)
}

task('generate') {
dependsOn subprojects.collect { it.getTasksByName('generateProtocolClassFiles', true) }
dependsOn subprojects.collect { it.getTasksByName('generateJsonSchema2Pojo', true) }
Expand Down
1 change: 0 additions & 1 deletion docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@
* [Contributing to Airbyte](contributing-to-airbyte/README.md)
* [Code of Conduct](contributing-to-airbyte/code-of-conduct.md)
* [Developing Locally](contributing-to-airbyte/developing-locally.md)
* [Developing on Docker](contributing-to-airbyte/developing-on-docker.md)
* [Developing on Kubernetes](contributing-to-airbyte/developing-on-kubernetes.md)
* [Monorepo Python Development](contributing-to-airbyte/monorepo-python-development.md)
* [Code Style](contributing-to-airbyte/code-style.md)
Expand Down
Loading

0 comments on commit 554e508

Please sign in to comment.