fix: Better queue system + more support on monorepos
This commit is contained in:
@@ -84,7 +84,15 @@ export function makeLabelForServices(type) {
|
||||
}
|
||||
|
||||
export const setDefaultConfiguration = async (data) => {
|
||||
let { buildPack, port, installCommand, startCommand, buildCommand, publishDirectory } = data;
|
||||
let {
|
||||
buildPack,
|
||||
port,
|
||||
installCommand,
|
||||
startCommand,
|
||||
buildCommand,
|
||||
publishDirectory,
|
||||
baseDirectory
|
||||
} = data;
|
||||
const template = scanningTemplates[buildPack];
|
||||
if (!port) {
|
||||
port = template?.port || 3000;
|
||||
@@ -97,6 +105,10 @@ export const setDefaultConfiguration = async (data) => {
|
||||
if (!startCommand) startCommand = template?.startCommand || 'yarn start';
|
||||
if (!buildCommand) buildCommand = template?.buildCommand || null;
|
||||
if (!publishDirectory) publishDirectory = template?.publishDirectory || null;
|
||||
if (baseDirectory) {
|
||||
if (!baseDirectory.startsWith('/')) baseDirectory = `/${baseDirectory}`;
|
||||
if (!baseDirectory.endsWith('/')) baseDirectory = `${baseDirectory}/`;
|
||||
}
|
||||
|
||||
return {
|
||||
buildPack,
|
||||
@@ -104,7 +116,8 @@ export const setDefaultConfiguration = async (data) => {
|
||||
installCommand,
|
||||
startCommand,
|
||||
buildCommand,
|
||||
publishDirectory
|
||||
publishDirectory,
|
||||
baseDirectory
|
||||
};
|
||||
};
|
||||
|
||||
@@ -175,3 +188,11 @@ export async function copyBaseConfigurationFiles(buildPack, workdir, buildId, ap
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
export function checkPnpm(installCommand = null, buildCommand = null, startCommand = null) {
|
||||
return (
|
||||
installCommand?.includes('pnpm') ||
|
||||
buildCommand?.includes('pnpm') ||
|
||||
startCommand?.includes('pnpm')
|
||||
);
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { buildImage } from '$lib/docker';
|
||||
import { promises as fs } from 'fs';
|
||||
import { checkPnpm } from './common';
|
||||
|
||||
const createDockerfile = async (data, image): Promise<void> => {
|
||||
const {
|
||||
@@ -13,10 +14,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
||||
pullmergeRequestId
|
||||
} = data;
|
||||
const Dockerfile: Array<string> = [];
|
||||
const isPnpm =
|
||||
installCommand.includes('pnpm') ||
|
||||
buildCommand.includes('pnpm') ||
|
||||
startCommand.includes('pnpm');
|
||||
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||
Dockerfile.push(`FROM ${image}`);
|
||||
Dockerfile.push('WORKDIR /usr/src/app');
|
||||
Dockerfile.push(`LABEL coolify.image=true`);
|
||||
@@ -39,17 +37,9 @@ const createDockerfile = async (data, image): Promise<void> => {
|
||||
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||
}
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
||||
try {
|
||||
await fs.stat(`${workdir}/yarn.lock`);
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''}yarn.lock ./`);
|
||||
} catch (error) {}
|
||||
try {
|
||||
await fs.stat(`${workdir}/pnpm-lock.yaml`);
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''}pnpm-lock.yaml ./`);
|
||||
} catch (error) {}
|
||||
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||
Dockerfile.push(`RUN ${installCommand}`);
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''} ./`);
|
||||
|
||||
if (buildCommand) {
|
||||
Dockerfile.push(`RUN ${buildCommand}`);
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { buildImage } from '$lib/docker';
|
||||
import { promises as fs } from 'fs';
|
||||
import { checkPnpm } from './common';
|
||||
|
||||
const createDockerfile = async (data, image): Promise<void> => {
|
||||
const {
|
||||
@@ -13,10 +14,8 @@ const createDockerfile = async (data, image): Promise<void> => {
|
||||
pullmergeRequestId
|
||||
} = data;
|
||||
const Dockerfile: Array<string> = [];
|
||||
const isPnpm =
|
||||
installCommand.includes('pnpm') ||
|
||||
buildCommand.includes('pnpm') ||
|
||||
startCommand.includes('pnpm');
|
||||
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||
|
||||
Dockerfile.push(`FROM ${image}`);
|
||||
Dockerfile.push('WORKDIR /usr/src/app');
|
||||
Dockerfile.push(`LABEL coolify.image=true`);
|
||||
@@ -39,17 +38,8 @@ const createDockerfile = async (data, image): Promise<void> => {
|
||||
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||
}
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
||||
try {
|
||||
await fs.stat(`${workdir}/yarn.lock`);
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''}yarn.lock ./`);
|
||||
} catch (error) {}
|
||||
try {
|
||||
await fs.stat(`${workdir}/pnpm-lock.yaml`);
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''}pnpm-lock.yaml ./`);
|
||||
} catch (error) {}
|
||||
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||
Dockerfile.push(`RUN ${installCommand}`);
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''} ./`);
|
||||
if (buildCommand) {
|
||||
Dockerfile.push(`RUN ${buildCommand}`);
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { buildImage } from '$lib/docker';
|
||||
import { promises as fs } from 'fs';
|
||||
import { checkPnpm } from './common';
|
||||
|
||||
const createDockerfile = async (data, image): Promise<void> => {
|
||||
const {
|
||||
@@ -13,10 +14,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
||||
pullmergeRequestId
|
||||
} = data;
|
||||
const Dockerfile: Array<string> = [];
|
||||
const isPnpm =
|
||||
installCommand.includes('pnpm') ||
|
||||
buildCommand.includes('pnpm') ||
|
||||
startCommand.includes('pnpm');
|
||||
const isPnpm = checkPnpm(installCommand, buildCommand, startCommand);
|
||||
Dockerfile.push(`FROM ${image}`);
|
||||
Dockerfile.push('WORKDIR /usr/src/app');
|
||||
Dockerfile.push(`LABEL coolify.image=true`);
|
||||
@@ -39,17 +37,8 @@ const createDockerfile = async (data, image): Promise<void> => {
|
||||
Dockerfile.push('RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm');
|
||||
Dockerfile.push('RUN pnpm add -g pnpm');
|
||||
}
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''}package*.json ./`);
|
||||
try {
|
||||
await fs.stat(`${workdir}/yarn.lock`);
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''}yarn.lock ./`);
|
||||
} catch (error) {}
|
||||
try {
|
||||
await fs.stat(`${workdir}/pnpm-lock.yaml`);
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''}pnpm-lock.yaml ./`);
|
||||
} catch (error) {}
|
||||
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||
Dockerfile.push(`RUN ${installCommand}`);
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''} ./`);
|
||||
if (buildCommand) {
|
||||
Dockerfile.push(`RUN ${buildCommand}`);
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
||||
Dockerfile.push(`LABEL coolify.image=true`);
|
||||
Dockerfile.push('RUN a2enmod rewrite');
|
||||
Dockerfile.push('WORKDIR /var/www/html');
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''} /var/www/html`);
|
||||
Dockerfile.push(`COPY .${baseDirectory || ''} /var/www/html`);
|
||||
Dockerfile.push(`EXPOSE 80`);
|
||||
Dockerfile.push('CMD ["apache2-foreground"]');
|
||||
Dockerfile.push('RUN chown -R www-data /var/www/html');
|
||||
|
@@ -37,7 +37,7 @@ const createDockerfile = async (data, image): Promise<void> => {
|
||||
`COPY --from=${applicationId}:${tag}-cache /usr/src/app/${publishDirectory} ./`
|
||||
);
|
||||
} else {
|
||||
Dockerfile.push(`COPY ./${baseDirectory || ''} ./`);
|
||||
Dockerfile.push(`COPY .${baseDirectory || ''} ./`);
|
||||
}
|
||||
Dockerfile.push(`EXPOSE 80`);
|
||||
Dockerfile.push('CMD ["nginx", "-g", "daemon off;"]');
|
||||
|
Reference in New Issue
Block a user