Skip to content

Commit

Permalink
finalize build-image task for OC app
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaffter committed Oct 9, 2024
1 parent 5932f25 commit 7dcf730
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
12 changes: 0 additions & 12 deletions apps/openchallenges/app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,6 @@
"jestConfig": "apps/openchallenges/app/jest.config.ts"
}
},
"build-image": {
"executor": "@nx-tools/nx-container:build",
"options": {
"context": ".",
"metadata": {
"images": ["ghcr.io/sage-bionetworks/openchallenges-app"],
"tags": ["type=edge,branch=main", "type=raw,value=local", "type=sha"]
},
"push": false
},
"dependsOn": ["server"]
},
"publish-image": {
"executor": "@nx-tools/nx-container:build",
"options": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
import { TargetConfiguration } from '@nx/devkit';
import { ProjectBuilder } from './project-builder';
import { Builder } from './project-metadata';

export async function buildImageTarget(
projectRoot: string,
projectName: string,
projectBuilder: ProjectBuilder | undefined,
projectBuilder: Builder | undefined | null, // TODO: builder could be app or image, be more specific
): Promise<TargetConfiguration> {
const dependsOn = [
{
target: 'build',
},
];
const dependsOn = [];
if (projectBuilder === 'gradle') {
dependsOn.push({
target: 'build-image-base',
});
} else if (projectBuilder === 'webpack') {
dependsOn.push({
// TODO: the task `server` is more about Angular that the build itself. To revisit. Also,
// shall we let the user decide between CSR and SSR?
target: 'server',
});
} else {
dependsOn.push({
target: 'build',
});
}

let context = projectRoot;
// TODO: The context must be set to '.' for Angular app. Be more specific.
if (projectBuilder === 'webpack') {
context = '.';
}

return {
executor: '@nx-tools/nx-container:build',
outputs: [],

options: {
context: projectRoot,
context,
},
cache: false,
configurations: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ export async function buildProjectConfiguration(
targets[pluginConfig.buildImageTargetName] = await buildImageTarget(
options.projectRoot,
options.projectName,
options.projectBuilder,
options.projectMetadata.builder,
);
}

const metadata = {};
const tags: string[] = [];
if (options.projectBuilder) {
tags.push(`builder:${options.projectBuilder}`);
if (options.projectMetadata.builder) {
tags.push(`builder:${options.projectMetadata.builder}`);
}

return { targets, metadata, tags };
Expand Down
8 changes: 4 additions & 4 deletions libs/sage-monorepo/nx-sage-monorepo/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ async function createNodesInternal(
if (typeof projectName !== 'string') {
throw new Error('Project name is undefined or not a valid string.');
}
console.log(`projectName: ${projectName}`);
// console.log(`projectName: ${projectName}`);

const projectType = inferProjectType(projectRoot);
console.log(`projectType: ${projectType}`);
// console.log(`projectType: ${projectType}`);

const dockerized = projectType === 'application' && siblingFiles.includes('Dockerfile');
console.log(`dockerized: ${dockerized}`);
// console.log(`dockerized: ${dockerized}`);

const projectMetadata = inferProjectMetadata(workspaceRoot, projectRoot, projectFileContent);
console.log(`projectMetadata: ${JSON.stringify(projectMetadata)}`);
// console.log(`projectMetadata: ${JSON.stringify(projectMetadata)}`);

const pluginConfig = createPluginConfiguration(options || {});

Expand Down

0 comments on commit 7dcf730

Please sign in to comment.