diff --git a/cli/cmd/create.go b/cli/cmd/create.go index 21a8468e7c..b026dd9a47 100644 --- a/cli/cmd/create.go +++ b/cli/cmd/create.go @@ -92,8 +92,8 @@ func init() { &localPath, "path", "p", - ".", - "if local build, the path to the build directory", + "", + "if local build, the path to the build directory (default: Dockerfile directory)", ) createCmd.PersistentFlags().StringVar( @@ -164,6 +164,10 @@ func createFull(resp *api.AuthCheckResponse, client *api.Client, args []string) color.New(color.FgGreen).Printf("Creating %s release: %s\n", args[0], name) + if localPath == "" { + localPath = filepath.Dir(dockerfile) + } + fullPath, err := filepath.Abs(localPath) if err != nil { diff --git a/cli/cmd/deploy.go b/cli/cmd/deploy.go index 763875842f..c11d41a6e4 100644 --- a/cli/cmd/deploy.go +++ b/cli/cmd/deploy.go @@ -234,8 +234,8 @@ func init() { &localPath, "path", "p", - ".", - "If local build, the path to the build directory. If remote build, the relative path from the repository root to the build directory.", + "", + "If local build, the path to the build directory. If remote build, the relative path from the repository root to the build directory. (default: Dockerfile directory)", ) updateCmd.PersistentFlags().StringVarP( diff --git a/cli/cmd/deploy/create.go b/cli/cmd/deploy/create.go index 3d51668844..ff6dc10cbb 100644 --- a/cli/cmd/deploy/create.go +++ b/cli/cmd/deploy/create.go @@ -280,7 +280,13 @@ func (c *CreateAgent) CreateFromDocker( } if opts.Method == DeployBuildTypeDocker { - err = buildAgent.BuildDocker(agent, opts.LocalPath, ".", opts.LocalDockerfile, "latest") + basePath, err := filepath.Abs(".") + + if err != nil { + return "", err + } + + err = buildAgent.BuildDocker(agent, basePath, opts.LocalPath, opts.LocalDockerfile, "latest") } else { err = buildAgent.BuildPack(agent, opts.LocalPath, "latest") } diff --git a/cli/cmd/deploy/deploy.go b/cli/cmd/deploy/deploy.go index 1fb4302dac..e2d73ed1bf 100644 --- a/cli/cmd/deploy/deploy.go +++ b/cli/cmd/deploy/deploy.go @@ -131,6 +131,13 @@ func NewDeployAgent(client *api.Client, app string, opts *DeployOpts) (*DeployAg deployAgent.dockerfilePath = deployAgent.opts.LocalDockerfile } else { deployAgent.imageRepo = release.GitActionConfig.ImageRepoURI + deployAgent.opts.LocalPath = release.GitActionConfig.FolderPath + } + + if deployAgent.opts.Method == DeployBuildTypeDocker { + if deployAgent.opts.LocalPath == "" { + deployAgent.opts.LocalPath = filepath.Dir(deployAgent.dockerfilePath) + } } deployAgent.tag = opts.OverrideTag diff --git a/dashboard/src/components/repo-selector/ActionConfEditor.tsx b/dashboard/src/components/repo-selector/ActionConfEditor.tsx index b9d9dd6878..e27dd7c1cd 100644 --- a/dashboard/src/components/repo-selector/ActionConfEditor.tsx +++ b/dashboard/src/components/repo-selector/ActionConfEditor.tsx @@ -67,44 +67,26 @@ const ActionConfEditor: React.FC = (props) => { ); - } else if (!props.dockerfilePath && !props.folderPath) { - return ( - <> - props.setDockerfilePath(x)} - setProcfilePath={(x: string) => props.setProcfilePath(x)} - setFolderPath={(x: string) => props.setFolderPath(x)} - /> -
- { - setBranch(""); - }} - > - keyboard_backspace - Select Branch - - - ); - } - - if ( - props.procfilePath && - props.folderPath && - !props.dockerfilePath && - !props.procfileProcess + } else if ( + // select dockerfile or buildpack build context + (!props.dockerfilePath && !props.folderPath) || + // select procfile process + (props.procfilePath && + props.folderPath && + !props.dockerfilePath && + !props.procfileProcess) || + // select docker build context + (props.dockerfilePath && !props.folderPath) ) { return ( <> props.setDockerfilePath(x)} setProcfilePath={(x: string) => props.setProcfilePath(x)} setProcfileProcess={(x: string) => props.setProcfileProcess(x)} @@ -115,6 +97,7 @@ const ActionConfEditor: React.FC = (props) => { width="145px" onClick={() => { setBranch(""); + props.setDockerfilePath(""); }} > keyboard_backspace diff --git a/dashboard/src/components/repo-selector/ActionDetails.tsx b/dashboard/src/components/repo-selector/ActionDetails.tsx index 940c086031..feaf5fa946 100644 --- a/dashboard/src/components/repo-selector/ActionDetails.tsx +++ b/dashboard/src/components/repo-selector/ActionDetails.tsx @@ -124,7 +124,7 @@ export default class ActionDetails extends Component { width="100%" value={this.props.branch} /> - {this.props.dockerfilePath ? ( + {this.props.dockerfilePath && ( { width="100%" value={this.props.dockerfilePath} /> - ) : ( - )} + {this.renderRegistrySection()}
diff --git a/dashboard/src/components/repo-selector/ContentsList.tsx b/dashboard/src/components/repo-selector/ContentsList.tsx index 695e0d241b..e1d4519cfc 100644 --- a/dashboard/src/components/repo-selector/ContentsList.tsx +++ b/dashboard/src/components/repo-selector/ContentsList.tsx @@ -19,6 +19,8 @@ interface AutoBuildpack { type PropsType = { actionConfig: ActionConfigType | null; branch: string; + dockerfilePath?: string; + folderPath: string; procfilePath?: string; setActionConfig: (x: ActionConfigType) => void; setProcfileProcess?: (x: string) => void; @@ -35,6 +37,7 @@ type StateType = { dockerfiles: string[]; processes: Record; autoBuildpack: AutoBuildpack; + showingBuildContextPrompt: boolean; }; export default class ContentsList extends Component { @@ -49,6 +52,7 @@ export default class ContentsList extends Component { valid: false, name: "", }, + showingBuildContextPrompt: true, }; componentDidMount() { @@ -184,7 +188,7 @@ export default class ContentsList extends Component { ); } - if (fileName.includes("Dockerfile")) { + if (fileName.includes("Dockerfile") && !this.props.dockerfilePath) { return ( { return ( - Select Application Folder + Select{" "} + {this.props.dockerfilePath + ? "Docker Build Context" + : "Application Folder"} ); }; handleContinue = () => { + if (this.props.dockerfilePath) { + this.props.setFolderPath(this.state.currentDir || "./"); + return; + } + let dockerfiles = [] as string[]; this.state.contents.forEach((item: FileType, i: number) => { let splits = item.Path.split("/"); @@ -319,7 +331,7 @@ export default class ContentsList extends Component { ); } - if (this.state.dockerfiles.length > 0) { + if (this.state.dockerfiles.length > 0 && !this.props.dockerfilePath) { return ( this.setState({ dockerfiles: [] })} /> @@ -364,6 +376,45 @@ export default class ContentsList extends Component { ); } + if ( + this.props.dockerfilePath && + !this.props.folderPath && + this.state.showingBuildContextPrompt + ) { + return ( + + this.props.setDockerfilePath("")} /> + + this.props.setFolderPath(this.state.currentDir || "./") + } + > + + + + + { + this.setState({ showingBuildContextPrompt: false }); + this.setSubdirectory(""); + }} + > + Yes + + + this.props.setFolderPath(this.state.currentDir || "./") + } + > + No + + + + ); + } }; render() { @@ -477,12 +528,18 @@ const Indicator = styled.div<{ selected: boolean }>` `; const Label = styled.div` - max-width: 420px; + max-width: 500px; line-height: 1.5em; text-align: center; font-size: 14px; `; +const MultiSelectRow = styled.div` + display: flex; + min-width: 150px; + justify-content: space-between; +`; + const DockerfileList = styled.div` border-radius: 3px; margin-top: 20px; diff --git a/dashboard/src/main/home/launch/launch-flow/SourcePage.tsx b/dashboard/src/main/home/launch/launch-flow/SourcePage.tsx index 086dd3c811..73265f88a5 100644 --- a/dashboard/src/main/home/launch/launch-flow/SourcePage.tsx +++ b/dashboard/src/main/home/launch/launch-flow/SourcePage.tsx @@ -147,7 +147,15 @@ class SourcePage extends Component { } = this.props; return ( - setSourceType("")}> + { + setSourceType(""); + setDockerfilePath(""); + setFolderPath(""); + setProcfilePath(""); + setProcfileProcess(""); + }} + > diff --git a/server/api/deploy_handler.go b/server/api/deploy_handler.go index 72f0cc0f00..37e27993af 100644 --- a/server/api/deploy_handler.go +++ b/server/api/deploy_handler.go @@ -186,6 +186,7 @@ func (app *App) HandleDeployTemplate(w http.ResponseWriter, r *http.Request) { GitBranch: form.GithubActionConfig.GitBranch, ImageRepoURI: form.GithubActionConfig.ImageRepoURI, DockerfilePath: form.GithubActionConfig.DockerfilePath, + FolderPath: form.GithubActionConfig.FolderPath, GitRepoID: form.GithubActionConfig.GitRepoID, RegistryID: form.GithubActionConfig.RegistryID,