Skip to content

Commit

Permalink
Provide docker-web project for gradle, restructure web static content
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Dec 15, 2021
1 parent 815b2d7 commit 8683ee9
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 94 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Set<Project> modsAreBasic = subprojects.findAll {it.name in [
'deephaven2-wheel',
'envoy',
'grpc-proxy',
'web',
'web-client-ui',
'pyclient',
'sphinx',
Expand Down Expand Up @@ -480,7 +481,7 @@ tasks.register('prepareCompose') {
it.description 'A lifecycle task that prepares prerequisites for local docker-compose builds'
it.dependsOn project(':docker-server-slim').tasks.findByName('buildDocker'),
project(':docker-server').tasks.findByName('buildDocker-server'),
project(':web-client-ide').tasks.findByName('buildDocker'),
project(':docker-web').tasks.findByName('buildDocker'),
project(':envoy').tasks.findByName('buildDocker'),
project(':grpc-proxy').tasks.findByName('buildDocker')
}
Expand All @@ -496,7 +497,7 @@ tasks.register('smoke') {
it.dependsOn project(':grpc-api').tasks.findByName(LifecycleBasePlugin.CHECK_TASK_NAME)
it.dependsOn project(':docker-server-slim').tasks.findByName('prepareDocker')
it.dependsOn project(':docker-server').tasks.findByName('prepareDocker')
it.dependsOn project(':web-client-ide').tasks.findByName('prepareDocker')
it.dependsOn project(':web').tasks.findByName(LifecycleBasePlugin.ASSEMBLE_TASK_NAME)
it.dependsOn project(':Generators').tasks.findByName(LifecycleBasePlugin.CHECK_TASK_NAME)
}

Expand Down
34 changes: 0 additions & 34 deletions buildSrc/src/main/groovy/GwtTools.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import groovy.transform.CompileStatic
import org.gradle.api.Project
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.CopySpec
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.TaskOutputs
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.compile.JavaCompile

/**
Expand Down Expand Up @@ -72,37 +69,6 @@ class GwtTools {
gwtc.logger.quiet('Running in gwt dev mode; saving source to {}/dh/src', extras)
}

// Add a jar task to create an artifact containing our compiled application
p.tasks.register "jsJar", Jar, {
Jar j ->
j.group = '~Deephaven'
j.description = description
// make a task dependency, AND make sure we rebuild this jar if the gwtc task output files change.
j.inputs.files gwtc.outputs.files
j.from("$gwt.compile.war/dhapi") {
CopySpec c->
c.exclude '**/extra' // don't put our source files in exported jar, thx
c.into 'dhapi'
}
// let's also pull in the ide client's build output
TaskOutputs uiOutputs = p.project(':web-client-ui').tasks.getByName('ideClient').outputs
j.from(uiOutputs.files) {
CopySpec c ->
c.into 'dhide'
}

TaskOutputs internalOpenapiOutputs = p.project(':proto:raw-js-openapi').tasks.getByName('webpackSources').outputs
j.from(internalOpenapiOutputs.files) {
CopySpec c ->
c.into 'dhapi'
}

j.classifier = 'js'
j.doFirst {
j.logger.info "Merging $gwt.compile.war and $uiOutputs into $j.archivePath"
}
}

p.tasks.findByName('gwtCheck')?.enabled = false
}

Expand Down
37 changes: 37 additions & 0 deletions docker/web/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import io.deephaven.tools.License

plugins {
id 'com.bmuschko.docker-remote-api'
}

configurations {
js
}
dependencies {
js project(path: ':web', targetConfiguration: 'js')
}

evaluationDependsOn Docker.registryProject('nginx-base')

def dockerLicenses = License.createFrom(project).syncDockerLicense()

def syncDir = layout.buildDirectory.dir('docker')
def prepareDocker = project.tasks.register('prepareDocker', Sync) {
from layout.projectDirectory.dir('src/main/docker')
from(configurations.js) {
into 'static'
}
from (dockerLicenses.get().outputs) {
into 'licenses'
}
into syncDir
}

Docker.registerDockerImage(project, 'buildDocker') {
inputDir.set syncDir
inputs.files Docker.registryFiles(project, 'nginx-base')
inputs.files prepareDocker.get().outputs.files
images.add('deephaven/web:local-build')
}

assemble.dependsOn buildDocker
10 changes: 10 additions & 0 deletions docker/web/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM deephaven/nginx-base:local-build

COPY licenses/ /
COPY nginx/default.conf /etc/nginx/conf.d/
COPY nginx/nginx.conf /etc/nginx/
COPY nginx/99-init-notebooks.sh /docker-entrypoint.d

COPY static/ /usr/share/nginx/html

VOLUME /tmp
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 13 additions & 3 deletions proto/raw-js-openapi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ evaluationDependsOn ':proto:proto-backplane-grpc'
evaluationDependsOn Docker.registryProject('node')

def backplaneProject = project(':proto:proto-backplane-grpc')
def webpackSourcesLocation = "${buildDir}/dhapi"
def webpackSourcesLocation = layout.buildDirectory.dir("${buildDir}/dhapi")

Docker.registerDockerTask(project, 'webpackSources') {
copyIn {
Expand All @@ -30,12 +30,22 @@ Docker.registerDockerTask(project, 'webpackSources') {
from ('Dockerfile')
from ('../package.json')
from ('../package-lock.json')

}
parentContainers = [ Docker.registryTask(project, 'node') ]
imageName = 'deephaven/js-out:local-build'
containerOutPath = '/usr/src/app/raw-js-openapi/build/js-out'
copyOut {
into(webpackSourcesLocation)
include 'dh-internal.js'
into(webpackSourcesLocation.get().dir('jsapi'))
}
}

configurations {
js
}

artifacts {
js(webpackSourcesLocation) {
builtBy webpackSources
}
}
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ String[] mods = [ 'Util', 'Numerics', 'TableLogger', 'Plot',
// new web projects; these modules are intended to form a complete, modular web application,
// with heavy dependency isolation that should enable very fast rebuilds.
String[] webMods = [
'web',
'web-client-api', // compiled javascript api client
'web-client-ide', // IDE-only additions to open-api javascript client
'web-client-ui', // React IDE client app
Expand Down Expand Up @@ -245,6 +246,9 @@ project(':docker-runtime-base').projectDir = file('docker/runtime-base')
include(':docker-server')
project(':docker-server').projectDir = file('docker/server')

include(':docker-web')
project(':docker-web').projectDir = file('docker/web')

include(':docker-server-slim')
project(':docker-server-slim').projectDir = file('docker/server-slim')

Expand Down
56 changes: 18 additions & 38 deletions web/client-ide/client-ide.gradle
Original file line number Diff line number Diff line change
@@ -1,57 +1,37 @@
import io.deephaven.tools.License

plugins {
id 'com.bmuschko.docker-remote-api'
}

evaluationDependsOn ':web-client-ui'
evaluationDependsOn ':proto:raw-js-openapi'
evaluationDependsOn Docker.registryProject('nginx-base')

apply from: "$rootDir/gradle/web-client.gradle"

configurations {
js
}

dependencies {
compile project(':web-client-api')
compile project(':open-api-lang-parser')

js project(path: ':proto:raw-js-openapi', configuration: 'js')
}

GwtTools.gwtCompile project, 'io.deephaven.ide.DeephavenIde', 'Create a jar of javascript for web IDE'

// deephaven/dhide
Task dhide = project(':web-client-ui').tasks.findByName('ideClientMakeImage')

// deephaven/js-out
Task jsOut = project(':proto:raw-js-openapi').tasks.findByName('webpackSourcesMakeImage')

Task gwtc = tasks.getByName('gwtCompile')

def dockerLicenses = License.createFrom(project).syncDockerLicense()

def prepareDocker = project.tasks.register('prepareDocker', Sync) {
// TODO(deephaven-core#1596): Remove extra dependencies for build-ci.yml
// Note: GH actions currently prepares docker via gradle, but does its own building via
// a native GH action. As such, we need to make sure that the prepare also invokes the
// necessarily build pre-reqs. If GH actions eventually calls buildDocker instead, we
// can remove these dependencies.
inputs.files([dhide, jsOut].each { t -> t.outputs.files })
inputs.files Docker.registryFiles(project, 'nginx-base')

into "${buildDir}/docker"
from(gwtc.outputs.files) {
include("dhapi/**")
def jsOutput = layout.buildDirectory.dir('js')
def gwtOutput = tasks.register('gwtOutput', Sync) {
includeEmptyDirs = false
from(tasks.getByName('gwtCompile').outputs.files) {
// only copy the dhapi module, and don't give it a wrapper directory
include 'dhapi/**'
eachFile { it.path = 'jsapi/' + it.path.substring('dhapi/'.length()) }
}
from (dockerLicenses.get().outputs) {
into 'licenses'
}
from 'docker/Dockerfile'
from 'nginx/default.conf'
from 'nginx/nginx.conf'
from 'nginx/99-init-notebooks.sh'
into jsOutput
}

Docker.registerDockerImage(project, 'buildDocker') {
inputs.files([prepareDocker.get(), dhide, jsOut].each { t -> t.outputs.files })
inputs.files Docker.registryFiles(project, 'nginx-base')
//buildArgs.put('DEEPHAVEN_VERSION', "${project.version}")
images.add('deephaven/web:local-build')
artifacts {
js(jsOutput) {
builtBy gwtOutput
}
}
15 changes: 0 additions & 15 deletions web/client-ide/docker/Dockerfile

This file was deleted.

15 changes: 13 additions & 2 deletions web/client-ui/client-ui.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ plugins {

evaluationDependsOn Docker.registryProject('node')

Docker.registerDockerTask(project, 'ideClient') {
def dhUi = layout.buildDirectory.dir('dhide')
def ui = Docker.registerDockerTask(project, 'ui') {
copyIn {
from file('Dockerfile')
}
parentContainers = [ Docker.registryTask(project, 'node') ]
containerOutPath = '/usr/src/app/package/build'
imageName = 'deephaven/dhide:local-build'
copyOut {
into "${buildDir}/dhide"
into dhUi.get().dir('ide')
}
}

configurations {
js
}

artifacts {
js(dhUi) {
builtBy ui
}
}
24 changes: 24 additions & 0 deletions web/web.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
configurations {
js
jsJar {
transitive = false
}
}

dependencies {
js project(path: ':web-client-ui', configuration: 'js')
js project(path: ':web-client-ide', configuration: 'js')
}

/**
* Provides a jar full of static js/html/css that can be served from jetty
*/
def ideClientJsJar = tasks.register('ideClientJsJar', Jar) {
archivesBaseName = "deephaven-web"
from configurations.js
}

artifacts {
jsJar ideClientJsJar
js layout.buildDirectory.dir('empty')
}

0 comments on commit 8683ee9

Please sign in to comment.