fix: envs
This commit is contained in:
@@ -39,7 +39,6 @@
|
|||||||
"dayjs": "1.11.6",
|
"dayjs": "1.11.6",
|
||||||
"dockerode": "3.3.4",
|
"dockerode": "3.3.4",
|
||||||
"dotenv-extended": "2.9.0",
|
"dotenv-extended": "2.9.0",
|
||||||
"escape-string-regexp": "5.0.0",
|
|
||||||
"execa": "6.1.0",
|
"execa": "6.1.0",
|
||||||
"fastify": "4.10.2",
|
"fastify": "4.10.2",
|
||||||
"fastify-plugin": "4.3.0",
|
"fastify-plugin": "4.3.0",
|
||||||
|
@@ -56,7 +56,6 @@ import * as buildpacks from '../lib/buildPacks';
|
|||||||
|
|
||||||
for (const queueBuild of queuedBuilds) {
|
for (const queueBuild of queuedBuilds) {
|
||||||
actions.push(async () => {
|
actions.push(async () => {
|
||||||
const { default: escapeStringRegexp } = await import('escape-string-regexp');
|
|
||||||
let application = await prisma.application.findUnique({
|
let application = await prisma.application.findUnique({
|
||||||
where: { id: queueBuild.applicationId },
|
where: { id: queueBuild.applicationId },
|
||||||
include: {
|
include: {
|
||||||
@@ -141,7 +140,7 @@ import * as buildpacks from '../lib/buildPacks';
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
const envs = [`PORT=${port}`];
|
const envs = [`PORT='${port}'`];
|
||||||
if (secrets.length > 0) {
|
if (secrets.length > 0) {
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
@@ -149,25 +148,13 @@ import * as buildpacks from '../lib/buildPacks';
|
|||||||
(s) => s.name === secret.name && s.isPRMRSecret
|
(s) => s.name === secret.name && s.isPRMRSecret
|
||||||
);
|
);
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
envs.push(
|
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
|
||||||
`${secret.name}="${escapeStringRegexp(
|
|
||||||
isSecretFound[0].value.replace(/[\\$'"]/g, '\\$&')
|
|
||||||
)}"`
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
envs.push(
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
`${secret.name}="${escapeStringRegexp(
|
|
||||||
secret.value.replace(/[\\$'"]/g, '\\$&')
|
|
||||||
)}"`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
envs.push(
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
`${secret.name}="${escapeStringRegexp(
|
|
||||||
secret.value.replace(/[\\$'"]/g, '\\$&')
|
|
||||||
)}"`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -544,7 +531,6 @@ import * as buildpacks from '../lib/buildPacks';
|
|||||||
applicationId,
|
applicationId,
|
||||||
baseImage
|
baseImage
|
||||||
);
|
);
|
||||||
console.log({ secrets });
|
|
||||||
const labels = makeLabelForStandaloneApplication({
|
const labels = makeLabelForStandaloneApplication({
|
||||||
applicationId,
|
applicationId,
|
||||||
fqdn,
|
fqdn,
|
||||||
@@ -711,7 +697,7 @@ import * as buildpacks from '../lib/buildPacks';
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
const envs = [`PORT=${port}`];
|
const envs = [`PORT='${port}'`];
|
||||||
if (secrets.length > 0) {
|
if (secrets.length > 0) {
|
||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
@@ -719,18 +705,18 @@ import * as buildpacks from '../lib/buildPacks';
|
|||||||
(s) => s.name === secret.name && s.isPRMRSecret
|
(s) => s.name === secret.name && s.isPRMRSecret
|
||||||
);
|
);
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
envs.push(`${secret.name}=${isSecretFound[0].value}`);
|
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log({ envs });
|
console.log('hello');
|
||||||
await fs.writeFile(`${workdir}/.env`, envs.join('\n'));
|
await fs.writeFile(`${workdir}/.env`, envs.join('\n'));
|
||||||
if (dockerRegistry) {
|
if (dockerRegistry) {
|
||||||
const { url, username, password } = dockerRegistry;
|
const { url, username, password } = dockerRegistry;
|
||||||
|
@@ -1,17 +1,6 @@
|
|||||||
import {
|
import { base64Encode, decrypt, encrypt, executeCommand, generateTimestamp, getDomain, isARM, isDev, prisma, version } from "../common";
|
||||||
base64Encode,
|
|
||||||
decrypt,
|
|
||||||
encrypt,
|
|
||||||
executeCommand,
|
|
||||||
generateTimestamp,
|
|
||||||
getDomain,
|
|
||||||
isARM,
|
|
||||||
isDev,
|
|
||||||
prisma,
|
|
||||||
version
|
|
||||||
} from '../common';
|
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import { day } from '../dayjs';
|
import { day } from "../dayjs";
|
||||||
|
|
||||||
const staticApps = ['static', 'react', 'vuejs', 'svelte', 'gatsby', 'astro', 'eleventy'];
|
const staticApps = ['static', 'react', 'vuejs', 'svelte', 'gatsby', 'astro', 'eleventy'];
|
||||||
const nodeBased = [
|
const nodeBased = [
|
||||||
@@ -28,10 +17,7 @@ const nodeBased = [
|
|||||||
'nextjs'
|
'nextjs'
|
||||||
];
|
];
|
||||||
|
|
||||||
export function setDefaultBaseImage(
|
export function setDefaultBaseImage(buildPack: string | null, deploymentType: string | null = null) {
|
||||||
buildPack: string | null,
|
|
||||||
deploymentType: string | null = null
|
|
||||||
) {
|
|
||||||
const nodeVersions = [
|
const nodeVersions = [
|
||||||
{
|
{
|
||||||
value: 'node:lts',
|
value: 'node:lts',
|
||||||
@@ -330,8 +316,8 @@ export function setDefaultBaseImage(
|
|||||||
{
|
{
|
||||||
value: 'heroku/builder-classic:22',
|
value: 'heroku/builder-classic:22',
|
||||||
label: 'heroku/builder-classic:22'
|
label: 'heroku/builder-classic:22'
|
||||||
}
|
},
|
||||||
];
|
]
|
||||||
let payload: any = {
|
let payload: any = {
|
||||||
baseImage: null,
|
baseImage: null,
|
||||||
baseBuildImage: null,
|
baseBuildImage: null,
|
||||||
@@ -341,9 +327,7 @@ export function setDefaultBaseImage(
|
|||||||
if (nodeBased.includes(buildPack)) {
|
if (nodeBased.includes(buildPack)) {
|
||||||
if (deploymentType === 'static') {
|
if (deploymentType === 'static') {
|
||||||
payload.baseImage = isARM(process.arch) ? 'nginx:alpine' : 'webdevops/nginx:alpine';
|
payload.baseImage = isARM(process.arch) ? 'nginx:alpine' : 'webdevops/nginx:alpine';
|
||||||
payload.baseImages = isARM(process.arch)
|
payload.baseImages = isARM(process.arch) ? staticVersions.filter((version) => !version.value.includes('webdevops')) : staticVersions;
|
||||||
? staticVersions.filter((version) => !version.value.includes('webdevops'))
|
|
||||||
: staticVersions;
|
|
||||||
payload.baseBuildImage = 'node:lts';
|
payload.baseBuildImage = 'node:lts';
|
||||||
payload.baseBuildImages = nodeVersions;
|
payload.baseBuildImages = nodeVersions;
|
||||||
} else {
|
} else {
|
||||||
@@ -355,9 +339,7 @@ export function setDefaultBaseImage(
|
|||||||
}
|
}
|
||||||
if (staticApps.includes(buildPack)) {
|
if (staticApps.includes(buildPack)) {
|
||||||
payload.baseImage = isARM(process.arch) ? 'nginx:alpine' : 'webdevops/nginx:alpine';
|
payload.baseImage = isARM(process.arch) ? 'nginx:alpine' : 'webdevops/nginx:alpine';
|
||||||
payload.baseImages = isARM(process.arch)
|
payload.baseImages = isARM(process.arch) ? staticVersions.filter((version) => !version.value.includes('webdevops')) : staticVersions;
|
||||||
? staticVersions.filter((version) => !version.value.includes('webdevops'))
|
|
||||||
: staticVersions;
|
|
||||||
payload.baseBuildImage = 'node:lts';
|
payload.baseBuildImage = 'node:lts';
|
||||||
payload.baseBuildImages = nodeVersions;
|
payload.baseBuildImages = nodeVersions;
|
||||||
}
|
}
|
||||||
@@ -375,20 +357,12 @@ export function setDefaultBaseImage(
|
|||||||
payload.baseImage = 'denoland/deno:latest';
|
payload.baseImage = 'denoland/deno:latest';
|
||||||
}
|
}
|
||||||
if (buildPack === 'php') {
|
if (buildPack === 'php') {
|
||||||
payload.baseImage = isARM(process.arch)
|
payload.baseImage = isARM(process.arch) ? 'php:8.1-fpm-alpine' : 'webdevops/php-apache:8.2-alpine';
|
||||||
? 'php:8.1-fpm-alpine'
|
payload.baseImages = isARM(process.arch) ? phpVersions.filter((version) => !version.value.includes('webdevops')) : phpVersions
|
||||||
: 'webdevops/php-apache:8.2-alpine';
|
|
||||||
payload.baseImages = isARM(process.arch)
|
|
||||||
? phpVersions.filter((version) => !version.value.includes('webdevops'))
|
|
||||||
: phpVersions;
|
|
||||||
}
|
}
|
||||||
if (buildPack === 'laravel') {
|
if (buildPack === 'laravel') {
|
||||||
payload.baseImage = isARM(process.arch)
|
payload.baseImage = isARM(process.arch) ? 'php:8.1-fpm-alpine' : 'webdevops/php-apache:8.2-alpine';
|
||||||
? 'php:8.1-fpm-alpine'
|
payload.baseImages = isARM(process.arch) ? phpVersions.filter((version) => !version.value.includes('webdevops')) : phpVersions
|
||||||
: 'webdevops/php-apache:8.2-alpine';
|
|
||||||
payload.baseImages = isARM(process.arch)
|
|
||||||
? phpVersions.filter((version) => !version.value.includes('webdevops'))
|
|
||||||
: phpVersions;
|
|
||||||
payload.baseBuildImage = 'node:18';
|
payload.baseBuildImage = 'node:18';
|
||||||
payload.baseBuildImages = nodeVersions;
|
payload.baseBuildImages = nodeVersions;
|
||||||
}
|
}
|
||||||
@@ -431,8 +405,7 @@ export const setDefaultConfiguration = async (data: any) => {
|
|||||||
if (!publishDirectory) publishDirectory = template?.publishDirectory || null;
|
if (!publishDirectory) publishDirectory = template?.publishDirectory || null;
|
||||||
if (baseDirectory) {
|
if (baseDirectory) {
|
||||||
if (!baseDirectory.startsWith('/')) baseDirectory = `/${baseDirectory}`;
|
if (!baseDirectory.startsWith('/')) baseDirectory = `/${baseDirectory}`;
|
||||||
if (baseDirectory.endsWith('/') && baseDirectory !== '/')
|
if (baseDirectory.endsWith('/') && baseDirectory !== '/') baseDirectory = baseDirectory.slice(0, -1);
|
||||||
baseDirectory = baseDirectory.slice(0, -1);
|
|
||||||
}
|
}
|
||||||
if (dockerFileLocation) {
|
if (dockerFileLocation) {
|
||||||
if (!dockerFileLocation.startsWith('/')) dockerFileLocation = `/${dockerFileLocation}`;
|
if (!dockerFileLocation.startsWith('/')) dockerFileLocation = `/${dockerFileLocation}`;
|
||||||
@@ -441,10 +414,8 @@ export const setDefaultConfiguration = async (data: any) => {
|
|||||||
dockerFileLocation = '/Dockerfile';
|
dockerFileLocation = '/Dockerfile';
|
||||||
}
|
}
|
||||||
if (dockerComposeFileLocation) {
|
if (dockerComposeFileLocation) {
|
||||||
if (!dockerComposeFileLocation.startsWith('/'))
|
if (!dockerComposeFileLocation.startsWith('/')) dockerComposeFileLocation = `/${dockerComposeFileLocation}`;
|
||||||
dockerComposeFileLocation = `/${dockerComposeFileLocation}`;
|
if (dockerComposeFileLocation.endsWith('/')) dockerComposeFileLocation = dockerComposeFileLocation.slice(0, -1);
|
||||||
if (dockerComposeFileLocation.endsWith('/'))
|
|
||||||
dockerComposeFileLocation = dockerComposeFileLocation.slice(0, -1);
|
|
||||||
} else {
|
} else {
|
||||||
dockerComposeFileLocation = '/Dockerfile';
|
dockerComposeFileLocation = '/Dockerfile';
|
||||||
}
|
}
|
||||||
@@ -508,6 +479,7 @@ export const scanningTemplates = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const saveBuildLog = async ({
|
export const saveBuildLog = async ({
|
||||||
line,
|
line,
|
||||||
buildId,
|
buildId,
|
||||||
@@ -519,7 +491,7 @@ export const saveBuildLog = async ({
|
|||||||
}): Promise<any> => {
|
}): Promise<any> => {
|
||||||
if (buildId === 'undefined' || buildId === 'null' || !buildId) return;
|
if (buildId === 'undefined' || buildId === 'null' || !buildId) return;
|
||||||
if (applicationId === 'undefined' || applicationId === 'null' || !applicationId) return;
|
if (applicationId === 'undefined' || applicationId === 'null' || !applicationId) return;
|
||||||
const { default: got } = await import('got');
|
const { default: got } = await import('got')
|
||||||
if (typeof line === 'object' && line) {
|
if (typeof line === 'object' && line) {
|
||||||
if (line.shortMessage) {
|
if (line.shortMessage) {
|
||||||
line = line.shortMessage + '\n' + line.stderr;
|
line = line.shortMessage + '\n' + line.stderr;
|
||||||
@@ -532,11 +504,7 @@ export const saveBuildLog = async ({
|
|||||||
line = line.replace(regex, '<SENSITIVE_DATA_DELETED>@');
|
line = line.replace(regex, '<SENSITIVE_DATA_DELETED>@');
|
||||||
}
|
}
|
||||||
const addTimestamp = `[${generateTimestamp()}] ${line}`;
|
const addTimestamp = `[${generateTimestamp()}] ${line}`;
|
||||||
const fluentBitUrl = isDev
|
const fluentBitUrl = isDev ? process.env.COOLIFY_CONTAINER_DEV === 'true' ? 'http://coolify-fluentbit:24224' : 'http://localhost:24224' : 'http://coolify-fluentbit:24224';
|
||||||
? process.env.COOLIFY_CONTAINER_DEV === 'true'
|
|
||||||
? 'http://coolify-fluentbit:24224'
|
|
||||||
: 'http://localhost:24224'
|
|
||||||
: 'http://coolify-fluentbit:24224';
|
|
||||||
|
|
||||||
if (isDev && !process.env.COOLIFY_CONTAINER_DEV) {
|
if (isDev && !process.env.COOLIFY_CONTAINER_DEV) {
|
||||||
console.debug(`[${applicationId}] ${addTimestamp}`);
|
console.debug(`[${applicationId}] ${addTimestamp}`);
|
||||||
@@ -546,17 +514,15 @@ export const saveBuildLog = async ({
|
|||||||
json: {
|
json: {
|
||||||
line: encrypt(line)
|
line: encrypt(line)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return await prisma.buildLog.create({
|
return await prisma.buildLog.create({
|
||||||
data: {
|
data: {
|
||||||
line: addTimestamp,
|
line: addTimestamp, buildId, time: Number(day().valueOf()), applicationId
|
||||||
buildId,
|
|
||||||
time: Number(day().valueOf()),
|
|
||||||
applicationId
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function copyBaseConfigurationFiles(
|
export async function copyBaseConfigurationFiles(
|
||||||
@@ -644,7 +610,7 @@ export function checkPnpm(installCommand = null, buildCommand = null, startComma
|
|||||||
|
|
||||||
export async function saveDockerRegistryCredentials({ url, username, password, workdir }) {
|
export async function saveDockerRegistryCredentials({ url, username, password, workdir }) {
|
||||||
if (!username || !password) {
|
if (!username || !password) {
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
let decryptedPassword = decrypt(password);
|
let decryptedPassword = decrypt(password);
|
||||||
@@ -656,14 +622,14 @@ export async function saveDockerRegistryCredentials({ url, username, password, w
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
const payload = JSON.stringify({
|
const payload = JSON.stringify({
|
||||||
auths: {
|
"auths": {
|
||||||
[url]: {
|
[url]: {
|
||||||
auth: Buffer.from(`${username}:${decryptedPassword}`).toString('base64')
|
"auth": Buffer.from(`${username}:${decryptedPassword}`).toString('base64')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
await fs.writeFile(`${location}/config.json`, payload);
|
await fs.writeFile(`${location}/config.json`, payload)
|
||||||
return location;
|
return location
|
||||||
}
|
}
|
||||||
export async function buildImage({
|
export async function buildImage({
|
||||||
applicationId,
|
applicationId,
|
||||||
@@ -681,34 +647,22 @@ export async function buildImage({
|
|||||||
} else {
|
} else {
|
||||||
await saveBuildLog({ line: `Building production image...`, buildId, applicationId });
|
await saveBuildLog({ line: `Building production image...`, buildId, applicationId });
|
||||||
}
|
}
|
||||||
const dockerFile = isCache ? `${dockerFileLocation}-cache` : `${dockerFileLocation}`;
|
const dockerFile = isCache ? `${dockerFileLocation}-cache` : `${dockerFileLocation}`
|
||||||
const cache = `${applicationId}:${tag}${isCache ? '-cache' : ''}`;
|
const cache = `${applicationId}:${tag}${isCache ? '-cache' : ''}`
|
||||||
|
|
||||||
let location = null;
|
let location = null
|
||||||
|
|
||||||
const { dockerRegistry } = await prisma.application.findUnique({
|
const { dockerRegistry } = await prisma.application.findUnique({ where: { id: applicationId }, select: { dockerRegistry: true } })
|
||||||
where: { id: applicationId },
|
|
||||||
select: { dockerRegistry: true }
|
|
||||||
});
|
|
||||||
if (dockerRegistry) {
|
if (dockerRegistry) {
|
||||||
const { url, username, password } = dockerRegistry;
|
const { url, username, password } = dockerRegistry
|
||||||
location = await saveDockerRegistryCredentials({ url, username, password, workdir });
|
location = await saveDockerRegistryCredentials({ url, username, password, workdir })
|
||||||
}
|
}
|
||||||
|
|
||||||
await executeCommand({
|
await executeCommand({ stream: true, debug, buildId, applicationId, dockerId, command: `docker ${location ? `--config ${location}` : ''} build --progress plain -f ${workdir}/${dockerFile} -t ${cache} --build-arg SOURCE_COMMIT=${commit} ${workdir}` })
|
||||||
stream: true,
|
|
||||||
debug,
|
|
||||||
buildId,
|
|
||||||
applicationId,
|
|
||||||
dockerId,
|
|
||||||
command: `docker ${
|
|
||||||
location ? `--config ${location}` : ''
|
|
||||||
} build --progress plain -f ${workdir}/${dockerFile} -t ${cache} --build-arg SOURCE_COMMIT=${commit} ${workdir}`
|
|
||||||
});
|
|
||||||
|
|
||||||
const { status } = await prisma.build.findUnique({ where: { id: buildId } });
|
const { status } = await prisma.build.findUnique({ where: { id: buildId } })
|
||||||
if (status === 'canceled') {
|
if (status === 'canceled') {
|
||||||
throw new Error('Canceled.');
|
throw new Error('Canceled.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function makeLabelForSimpleDockerfile({ applicationId, port, type }) {
|
export function makeLabelForSimpleDockerfile({ applicationId, port, type }) {
|
||||||
@@ -772,7 +726,6 @@ export function makeLabelForStandaloneApplication({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function buildCacheImageWithNode(data, imageForBuild) {
|
export async function buildCacheImageWithNode(data, imageForBuild) {
|
||||||
const { default: escapeStringRegexp } = await import('escape-string-regexp');
|
|
||||||
const {
|
const {
|
||||||
workdir,
|
workdir,
|
||||||
buildId,
|
buildId,
|
||||||
@@ -791,15 +744,15 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
|
|||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
if (secret.isBuildSecret) {
|
if (secret.isBuildSecret) {
|
||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
|
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${escapeStringRegexp(isSecretFound[0].value)}`);
|
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${escapeStringRegexp(secret.value)}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${escapeStringRegexp(secret.value)}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -819,7 +772,6 @@ export async function buildCacheImageWithNode(data, imageForBuild) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function buildCacheImageForLaravel(data, imageForBuild) {
|
export async function buildCacheImageForLaravel(data, imageForBuild) {
|
||||||
const { default: escapeStringRegexp } = await import('escape-string-regexp');
|
|
||||||
const { workdir, buildId, secrets, pullmergeRequestId } = data;
|
const { workdir, buildId, secrets, pullmergeRequestId } = data;
|
||||||
|
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
@@ -830,15 +782,15 @@ export async function buildCacheImageForLaravel(data, imageForBuild) {
|
|||||||
secrets.forEach((secret) => {
|
secrets.forEach((secret) => {
|
||||||
if (secret.isBuildSecret) {
|
if (secret.isBuildSecret) {
|
||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
|
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${escapeStringRegexp(isSecretFound[0].value)}`);
|
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${escapeStringRegexp(secret.value)}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${escapeStringRegexp(secret.value)}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -852,7 +804,11 @@ export async function buildCacheImageForLaravel(data, imageForBuild) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function buildCacheImageWithCargo(data, imageForBuild) {
|
export async function buildCacheImageWithCargo(data, imageForBuild) {
|
||||||
const { applicationId, workdir, buildId } = data;
|
const {
|
||||||
|
applicationId,
|
||||||
|
workdir,
|
||||||
|
buildId,
|
||||||
|
} = data;
|
||||||
|
|
||||||
const Dockerfile: Array<string> = [];
|
const Dockerfile: Array<string> = [];
|
||||||
Dockerfile.push(`FROM ${imageForBuild} as planner-${applicationId}`);
|
Dockerfile.push(`FROM ${imageForBuild} as planner-${applicationId}`);
|
||||||
|
@@ -31,13 +31,13 @@ export default async function (data) {
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
|
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
envs.push(`${secret.name}=${isSecretFound[0].value}`);
|
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -29,13 +29,13 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
|
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ export default async function (data) {
|
|||||||
) {
|
) {
|
||||||
Dockerfile.forEach((line, index) => {
|
Dockerfile.forEach((line, index) => {
|
||||||
if (line.startsWith('FROM')) {
|
if (line.startsWith('FROM')) {
|
||||||
Dockerfile.splice(index + 1, 0, `ARG ${secret.name}=${secret.value}`);
|
Dockerfile.splice(index + 1, 0, `ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -29,13 +29,13 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
|
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@ import { promises as fs } from 'fs';
|
|||||||
import { buildImage, checkPnpm } from './common';
|
import { buildImage, checkPnpm } from './common';
|
||||||
|
|
||||||
const createDockerfile = async (data, image): Promise<void> => {
|
const createDockerfile = async (data, image): Promise<void> => {
|
||||||
const { default: escapeStringRegexp } = await import('escape-string-regexp');
|
|
||||||
const {
|
const {
|
||||||
workdir,
|
workdir,
|
||||||
port,
|
port,
|
||||||
@@ -26,13 +25,13 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
|
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${escapeStringRegexp(isSecretFound[0].value)}`);
|
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${escapeStringRegexp(secret.value)}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${escapeStringRegexp(secret.value)}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,13 +29,13 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
|
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,13 +18,13 @@ const createDockerfile = async (data, image, htaccessFound): Promise<void> => {
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
|
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,13 +23,13 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
|
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,13 +30,13 @@ const createDockerfile = async (data, image): Promise<void> => {
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${isSecretFound[0].value}`);
|
Dockerfile.push(`ARG ${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
Dockerfile.push(`ARG ${secret.name}=${secret.value}`);
|
Dockerfile.push(`ARG ${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -468,13 +468,13 @@ export async function restartApplication(request: FastifyRequest<RestartApplicat
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
envs.push(`${secret.name}=${isSecretFound[0].value}`);
|
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1169,13 +1169,13 @@ export async function restartPreview(request: FastifyRequest<RestartPreviewAppli
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
const isSecretFound = secrets.filter(s => s.name === secret.name && s.isPRMRSecret)
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
envs.push(`${secret.name}=${isSecretFound[0].value}`);
|
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -210,13 +210,13 @@ export const applicationsRouter = router({
|
|||||||
if (pullmergeRequestId) {
|
if (pullmergeRequestId) {
|
||||||
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
|
const isSecretFound = secrets.filter((s) => s.name === secret.name && s.isPRMRSecret);
|
||||||
if (isSecretFound.length > 0) {
|
if (isSecretFound.length > 0) {
|
||||||
envs.push(`${secret.name}=${isSecretFound[0].value}`);
|
envs.push(`${secret.name}='${isSecretFound[0].value}'`);
|
||||||
} else {
|
} else {
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!secret.isPRMRSecret) {
|
if (!secret.isPRMRSecret) {
|
||||||
envs.push(`${secret.name}=${secret.value}`);
|
envs.push(`${secret.name}='${secret.value}'`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@@ -43,7 +43,6 @@ importers:
|
|||||||
dockerode: 3.3.4
|
dockerode: 3.3.4
|
||||||
dotenv-extended: 2.9.0
|
dotenv-extended: 2.9.0
|
||||||
esbuild: 0.15.15
|
esbuild: 0.15.15
|
||||||
escape-string-regexp: 5.0.0
|
|
||||||
eslint: 8.28.0
|
eslint: 8.28.0
|
||||||
eslint-config-prettier: 8.5.0
|
eslint-config-prettier: 8.5.0
|
||||||
eslint-plugin-prettier: 4.2.1
|
eslint-plugin-prettier: 4.2.1
|
||||||
@@ -101,7 +100,6 @@ importers:
|
|||||||
dayjs: 1.11.6
|
dayjs: 1.11.6
|
||||||
dockerode: 3.3.4
|
dockerode: 3.3.4
|
||||||
dotenv-extended: 2.9.0
|
dotenv-extended: 2.9.0
|
||||||
escape-string-regexp: 5.0.0
|
|
||||||
execa: 6.1.0
|
execa: 6.1.0
|
||||||
fastify: 4.10.2
|
fastify: 4.10.2
|
||||||
fastify-plugin: 4.3.0
|
fastify-plugin: 4.3.0
|
||||||
|
Reference in New Issue
Block a user