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

FR: add build override options #1264

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/docker/DockerApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ class DockerApi {
tarballFilePath: string,
buildLogs: BuildLog,
envVars: IAppEnvVar[],
registryConfig: DockerRegistryConfig
registryConfig: DockerRegistryConfig,
overrideOptions: string[] | undefined
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must be renamed to dockerBuildOverrideOptions

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, will do.

) {
const self = this

Expand All @@ -268,6 +269,7 @@ class DockerApi {
const optionsForBuild: Dockerode.ImageBuildOptions = {
t: imageName,
buildargs: buildargs,
...overrideOptions,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this how it's passed to Dockerode? Isn't it using a key<>value pair structure?

Copy link
Author

@dTechLife dTechLife Nov 18, 2021

Choose a reason for hiding this comment

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

Great way to word that question; it isn't! I'll take a look at Dockerode and make sure I'm passing the variable correctly. :) Thank you for taking the time to review this for me!

I'll go through the concerns in the review, commit, build and test the functionality of the feature and change this from a draft after I confirm it works!

}

if (Object.keys(registryConfig).length > 0) {
Expand Down
1 change: 1 addition & 0 deletions src/models/AppDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ interface IAppDef extends IAppDefinitionBase {
httpAuth?: IHttpAuth
appName?: string
isAppBuilding?: boolean
overrideOptions?: string[]
}

interface IAppDefSaved extends IAppDefinitionBase {
Expand Down
12 changes: 8 additions & 4 deletions src/user/ImageMaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ export default class ImageMaker {
appName: string,
captainDefinitionRelativeFilePath: string,
appVersion: number,
envVars: IAppEnvVar[]
envVars: IAppEnvVar[],
overrideOptions: string[]
): Promise<IBuiltImage> {
const self = this

Expand Down Expand Up @@ -183,7 +184,8 @@ export default class ImageMaker {
baseImageNameWithoutVerAndReg,
appName,
appVersion,
envVars
envVars,
overrideOptions
)
})
})
Expand Down Expand Up @@ -245,7 +247,8 @@ export default class ImageMaker {
baseImageNameWithoutVersionAndReg: string,
appName: string,
appVersion: number,
envVars: IAppEnvVar[]
envVars: IAppEnvVar[],
overrideOptions?: string[]
) {
const self = this
return Promise.resolve() //
Expand All @@ -272,7 +275,8 @@ export default class ImageMaker {
tarFilePath,
self.buildLogsManager.getAppBuildLogs(appName),
envVars,
registryConfig
registryConfig,
overrideOptions
)
.catch(function (error: AnyError) {
throw ApiStatusCodes.createError(
Expand Down
4 changes: 3 additions & 1 deletion src/user/ServiceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,15 @@ class ServiceManager {
.getAppDefinition(appName)
.then(function (app) {
const envVars = app.envVars || []
const overrideOptions = app.overrideOptions || []

return self.imageMaker.ensureImage(
source,
appName,
app.captainDefinitionRelativeFilePath,
appVersion,
envVars
envVars,
overrideOptions
)
})
})
Expand Down
2 changes: 2 additions & 0 deletions src/utils/CaptainConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const configs = {
defaultEmail: 'runner@caprover.com',

captainSubDomain: 'captain',

overrideOptions: [],
}

const data = {
Expand Down