Skip to content

Commit

Permalink
Cleaning up docker build process
Browse files Browse the repository at this point in the history
  • Loading branch information
sundargates committed Sep 19, 2023
1 parent 1471f46 commit fa2e627
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 142 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/push-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: "Publish Docker images to Docker Registry"
on:
pull_request:
paths:
- ./mantis-control-plane/Dockerfile
- ./mantis-server/mantis-server-agent/Dockerfile
- ./mantis-control-plane/mantis-control-plane-server/build.gradle
- ./mantis-server/mantis-server-agent/build.gradle
- .github/workflows/push-docker-image.yml
push:
tags:
Expand All @@ -21,12 +21,14 @@ jobs:
fail-fast: false
matrix:
include:
- dockerfile: ./mantis-control-plane/Dockerfile
- dockerfile: ./mantis-control-plane/mantis-control-plane-server/build/docker/Dockerfile
image: "netflixoss/mantiscontrolplaneserver"
workingDirectory: ./mantis-control-plane
- dockerfile: ./mantis-server/mantis-server-agent/Dockerfile
workingDirectory: ./mantis-control-plane/mantis-control-plane-server/build/docker
target: mantis-control-plane:mantis-control-plane-server
- dockerfile: ./mantis-server/mantis-server-agent/build/docker/Dockerfile
image: "netflixoss/mantisagent"
workingDirectory: ./mantis-server/mantis-server-agent
target: mantis-server:mantis-server-agent
workingDirectory: ./mantis-server/mantis-server-agent/build/docker
permissions:
contents: read
packages: write
Expand All @@ -35,15 +37,15 @@ jobs:
- name: Checkout PR
uses: actions/checkout@v3

- name: Build executable
- name: Generate dockerfiles
uses: gradle/gradle-build-action@v2
env:
NETFLIX_OSS_SIGNING_KEY: ${{ secrets.ORG_SIGNING_KEY }}
NETFLIX_OSS_SIGNING_PASSWORD: ${{ secrets.ORG_SIGNING_PASSWORD }}
NETFLIX_OSS_REPO_USERNAME: ${{ secrets.ORG_NETFLIXOSS_USERNAME }}
NETFLIX_OSS_REPO_PASSWORD: ${{ secrets.ORG_NETFLIXOSS_PASSWORD }}
with:
arguments: installDist
arguments: --info --stacktrace ${{ matrix.target }}:dockerCreateDockerfile

- name: Fetch tags
run: |
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ buildscript {
classpath("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0")
classpath 'gradle.plugin.org.inferred:gradle-processors:3.3.0'
classpath 'com.palantir.baseline:gradle-baseline-java:4.0.0'
classpath 'com.bmuschko:gradle-docker-plugin:9.3.2'
}
}

Expand Down
35 changes: 0 additions & 35 deletions mantis-control-plane/Dockerfile

This file was deleted.

47 changes: 0 additions & 47 deletions mantis-control-plane/README.md

This file was deleted.

9 changes: 0 additions & 9 deletions mantis-control-plane/buildDockerImage.sh

This file was deleted.

1 change: 0 additions & 1 deletion mantis-control-plane/docker/SineFunction

This file was deleted.

38 changes: 38 additions & 0 deletions mantis-control-plane/mantis-control-plane-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ plugins {
}

apply plugin: 'application'
apply plugin: 'com.bmuschko.docker-java-application'

ext {
akkaVersion = '2.6.15'
Expand Down Expand Up @@ -62,6 +63,43 @@ dependencies {
testImplementation testFixtures(project(":mantis-control-plane:mantis-control-plane-core"))
testImplementation libraries.commonsIo
}
def installDir = file("${buildDir}/install")
def controlPlaneState = file("${project.resources}/docker")
def ci = System.getenv('GITHUB_ACTIONS')
def imageRepository = ci ? 'netflixoss' : 'localhost:5001/netflixoss'

docker {
dockerSyncBuildContext {
from installDir
from controlPlaneState
from('docker') {
into 'docker'
}
}

dockerCreateDockerfile {
instruction 'RUN apt-get update && apt-get install -y curl'

// instructions to install all the necessary dependencies
instruction 'WORKDIR /apps/mantis/mantis-control-plane-server'
instruction 'COPY mantis-control-plane-server/bin/* bin/'
instruction 'COPY mantis-control-plane-server/lib/* lib/'
instruction 'COPY resources/* conf/'
instruction 'COPY docker/job-clusters/* job-clusters/'
instruction 'COPY docker/bin/* bin/'

entryPoint './bin/start.sh'
}

javaApplication {
baseImage = 'azul/zulu-openjdk:8-latest'
maintainer = 'Mantis Developers "[email protected]"'
mainClassName = 'io.mantisrx.server.master.MasterMain'
images = ["$imageRepository/mantiscontrolplaneserver:latest"]
ports = [8100]
}
}
dockerSyncBuildContext.dependsOn(installDist)

mainClassName = "io.mantisrx.server.master.MasterMain"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jobNameInfo,{"name":"SineFunction","jars":[{"url":"http://mantis-examples-sine-function-2.1.0-SNAPSHOT.zip","uploadedAt":1571159980278,"version":"0.1.0-SNAPSHOT 2019-10-15 10:19:20","schedulingInfo":{"stages":{"1":{"numberOfInstances":1,"machineDefinition":{"cpuCores":1.0,"memoryMB":256.0,"networkMbps":12.0,"diskMB":10.0,"numPorts":1},"hardConstraints":[],"softConstraints":[],"scalingPolicy":null,"scalable":false}}}}],"sla":{"min":0,"max":0,"cronSpec":null,"cronPolicy":null},"parameters":[{"name":"useRandom","value":"true"}],"owner":{"name":"Mr. Mantis","teamName":"Mantis","description":"A simple job that generates x and y coordinates of a sine wave","contactEmail":"[email protected]","repo":"https://github.com/Netflix/mantis-examples/tree/master/sine-function"},"lastJobCount":0,"disabled":false,"isReadyForJobMaster":false,"migrationConfig":{"strategy":"PERCENTAGE","configString":"{\"percentToMove\":25,\"intervalMs\":60000}"},"labels":[{"name":"_mantis.user","value":"Mr. Mantis"},{"name":"_mantis.ownerEmail","value":"[email protected]"},{"name":"_mantis.artifact","value":"mantis-examples-sine-function-0.1.0-SNAPSHOT"},{"name":"_mantis.artifact.version","value":"SNAPSHOT"},{"name":"_mantis.jobType","value":""},{"name":"_mantis.criticality","value":""},{"name":"_mantis.resourceCluster","value":"DEFAULT_CLUSTER"}],"cronActive":false}
21 changes: 0 additions & 21 deletions mantis-server/mantis-server-agent/Dockerfile

This file was deleted.

43 changes: 37 additions & 6 deletions mantis-server/mantis-server-agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

apply plugin: 'application'
apply plugin: 'com.bmuschko.docker-java-application'

dependencies {
api project(":mantis-runtime-loader")
Expand All @@ -37,13 +38,43 @@ dependencies {
testImplementation(testFixtures(project(":mantis-control-plane:mantis-control-plane-core")))
}

tasks.register('copyPlaceholderFile', Copy) {
from 'src/test/resources/placeholder.txt'
into "${buildDir}/distributions"
}
def mantisExamplesSineFunction = project(":mantis-examples:mantis-examples-sine-function")
def mantisExamplesSineFunctionBuildDir = mantisExamplesSineFunction.buildDir
def mantisExamplesSineFunctionMantisZipArtifact = mantisExamplesSineFunction.tasks.named("mantisZipArtifact")
def installDir = file("${buildDir}/install")
def resourcesDir = file("${buildDir}/resources")
def ci = System.getenv('GITHUB_ACTIONS')
def imageRepository = ci ? 'netflixoss' : 'localhost:5001/netflixoss'

docker {
dockerSyncBuildContext {
from mantisExamplesSineFunctionBuildDir
from installDir
from resourcesDir
}

tasks.named('installDist') {
dependsOn copyPlaceholderFile
dockerCreateDockerfile {
instruction 'RUN apt-get update && apt-get install -y curl'
// root directory to store all the files
instruction 'WORKDIR /apps/mantis/mantis-server-agent'
// copy the files from the build context to the image
instruction 'COPY mantis-server-agent/bin/* /apps/mantis/mantis-server-agent/bin/'
instruction 'COPY mantis-server-agent/lib/* /apps/mantis/mantis-server-agent/lib/'
instruction 'COPY distributions/* mantis-artifacts/storage/'
instruction 'COPY resources/* conf/'
entryPoint 'bin/mantis-server-agent', '-p', 'conf/agent-docker.properties'
}

javaApplication {
baseImage = 'azul/zulu-openjdk:8-latest'
maintainer = 'Mantis Developers "[email protected]"'
mainClassName = 'io.mantisrx.server.agent.AgentV2Main'
images = ["$imageRepository/mantisagent:latest"]
ports = [5050]
}
}

dockerSyncBuildContext.dependsOn(installDist)
dockerSyncBuildContext.dependsOn(mantisExamplesSineFunctionMantisZipArtifact)

mainClassName = "io.mantisrx.server.agent.AgentV2Main"
15 changes: 0 additions & 15 deletions mantis-server/mantis-server-agent/buildDockerImage.sh

This file was deleted.

0 comments on commit fa2e627

Please sign in to comment.