fixes related to docker-compose

This commit is contained in:
Andras Bacsai
2023-01-16 09:44:08 +01:00
parent 5cb9216add
commit 18064ef6a2
11 changed files with 48 additions and 30 deletions

View File

@@ -351,13 +351,17 @@
}
async function reloadCompose() {
if (loading.reloadCompose) return;
if (!$appSession.tokens.github) {
const { token } = await get(`/applications/${id}/configuration/githubToken`);
$appSession.tokens.github = token;
}
loading.reloadCompose = true;
try {
if (application.gitSource.type === 'github') {
const composeLocation = application.dockerComposeFileLocation.startsWith('/')
? application.dockerComposeFileLocation
: `/${application.dockerComposeFileLocation}`;
? application.dockerComposeFileLocation
: `/${application.dockerComposeFileLocation}`;
const headers = isPublicRepository
? {}
: {
@@ -384,17 +388,17 @@
if (!$appSession.tokens.gitlab) {
await getGitlabToken();
}
const composeLocation = application.dockerComposeFileLocation.startsWith('/')
? application.dockerComposeFileLocation.substring(1) // Remove the '/' from the start
: application.dockerComposeFileLocation;
? application.dockerComposeFileLocation.substring(1) // Remove the '/' from the start
: application.dockerComposeFileLocation;
// If the file is in a subdirectory, lastIndex will be > 0
// Otherwise it will be -1 and path will be an empty string
const lastIndex = composeLocation.lastIndexOf('/') + 1
const path = composeLocation.substring(0, lastIndex)
const fileName = composeLocation.substring(lastIndex)
const lastIndex = composeLocation.lastIndexOf('/') + 1;
const path = composeLocation.substring(0, lastIndex);
const fileName = composeLocation.substring(lastIndex);
const headers = isPublicRepository
? {}
: {
@@ -407,8 +411,7 @@
...headers
});
const dockerComposeFileYml = files.find(
(file: { name: string; type: string }) =>
file.name === fileName && file.type === 'blob'
(file: { name: string; type: string }) => file.name === fileName && file.type === 'blob'
);
const id = dockerComposeFileYml.id;

View File

@@ -21,7 +21,7 @@
onMount(async () => {
const { data } = await trpc.applications.getApplicationById.query({ id });
application = data;
if (data.dockerComposeFile) {
if (application.dockerComposeFile && application.buildPack === 'compose') {
services = normalizeDockerServices(JSON.parse(data.dockerComposeFile).services);
} else {
services = [

View File

@@ -55,7 +55,7 @@
clearInterval(usageInterval);
});
onMount(async () => {
if (application.dockerComposeFile) {
if (application.dockerComposeFile && application.buildPack === 'compose') {
services = normalizeDockerServices(JSON.parse(application.dockerComposeFile).services);
} else {
services = [