2022-07-26 07:22:57 +00:00
import { base64Encode , executeDockerCmd , generateTimestamp , getDomain , isDev , prisma , version } from "../common" ;
2022-02-10 14:47:44 +00:00
import { promises as fs } from 'fs' ;
2022-07-06 09:02:36 +00:00
import { day } from "../dayjs" ;
2022-07-22 20:23:16 +00:00
2022-04-26 12:51:08 +00:00
const staticApps = [ 'static' , 'react' , 'vuejs' , 'svelte' , 'gatsby' , 'astro' , 'eleventy' ] ;
2022-05-02 11:00:13 +00:00
const nodeBased = [
'react' ,
2022-05-03 20:49:52 +00:00
'preact' ,
2022-05-02 11:00:13 +00:00
'vuejs' ,
'svelte' ,
'gatsby' ,
'astro' ,
'eleventy' ,
'node' ,
2022-05-03 20:49:52 +00:00
'nestjs' ,
'nuxtjs' ,
'nextjs'
2022-05-02 11:00:13 +00:00
] ;
2022-04-26 12:51:08 +00:00
2022-07-08 15:21:23 +00:00
export function setDefaultBaseImage ( buildPack : string | null , deploymentType : string | null = null ) {
2022-04-26 12:51:08 +00:00
const nodeVersions = [
{
value : 'node:lts' ,
label : 'node:lts'
} ,
{
value : 'node:18' ,
label : 'node:18'
} ,
{
value : 'node:17' ,
label : 'node:17'
} ,
{
value : 'node:16' ,
label : 'node:16'
} ,
{
value : 'node:14' ,
label : 'node:14'
} ,
{
value : 'node:12' ,
label : 'node:12'
}
] ;
const staticVersions = [
{
value : 'webdevops/nginx:alpine' ,
label : 'webdevops/nginx:alpine'
} ,
{
value : 'webdevops/apache:alpine' ,
label : 'webdevops/apache:alpine'
}
] ;
const rustVersions = [
{
value : 'rust:latest' ,
label : 'rust:latest'
} ,
{
value : 'rust:1.60' ,
label : 'rust:1.60'
} ,
{
value : 'rust:1.60-buster' ,
label : 'rust:1.60-buster'
} ,
{
value : 'rust:1.60-bullseye' ,
label : 'rust:1.60-bullseye'
} ,
{
value : 'rust:1.60-slim-buster' ,
label : 'rust:1.60-slim-buster'
} ,
{
value : 'rust:1.60-slim-bullseye' ,
label : 'rust:1.60-slim-bullseye'
} ,
{
value : 'rust:1.60-alpine3.14' ,
label : 'rust:1.60-alpine3.14'
} ,
{
value : 'rust:1.60-alpine3.15' ,
label : 'rust:1.60-alpine3.15'
}
] ;
const phpVersions = [
{
value : 'webdevops/php-apache:8.0' ,
label : 'webdevops/php-apache:8.0'
} ,
{
value : 'webdevops/php-nginx:8.0' ,
label : 'webdevops/php-nginx:8.0'
} ,
{
value : 'webdevops/php-apache:7.4' ,
label : 'webdevops/php-apache:7.4'
} ,
{
value : 'webdevops/php-nginx:7.4' ,
label : 'webdevops/php-nginx:7.4'
} ,
{
value : 'webdevops/php-apache:7.3' ,
label : 'webdevops/php-apache:7.3'
} ,
{
value : 'webdevops/php-nginx:7.3' ,
label : 'webdevops/php-nginx:7.3'
} ,
{
value : 'webdevops/php-apache:7.2' ,
label : 'webdevops/php-apache:7.2'
} ,
{
value : 'webdevops/php-nginx:7.2' ,
label : 'webdevops/php-nginx:7.2'
} ,
{
value : 'webdevops/php-apache:7.1' ,
label : 'webdevops/php-apache:7.1'
} ,
{
value : 'webdevops/php-nginx:7.1' ,
label : 'webdevops/php-nginx:7.1'
} ,
{
value : 'webdevops/php-apache:7.0' ,
label : 'webdevops/php-apache:7.0'
} ,
{
value : 'webdevops/php-nginx:7.0' ,
label : 'webdevops/php-nginx:7.0'
} ,
{
value : 'webdevops/php-apache:5.6' ,
label : 'webdevops/php-apache:5.6'
} ,
{
value : 'webdevops/php-nginx:5.6' ,
label : 'webdevops/php-nginx:5.6'
} ,
{
value : 'webdevops/php-apache:8.0-alpine' ,
label : 'webdevops/php-apache:8.0-alpine'
} ,
{
value : 'webdevops/php-nginx:8.0-alpine' ,
label : 'webdevops/php-nginx:8.0-alpine'
} ,
{
value : 'webdevops/php-apache:7.4-alpine' ,
label : 'webdevops/php-apache:7.4-alpine'
} ,
{
value : 'webdevops/php-nginx:7.4-alpine' ,
label : 'webdevops/php-nginx:7.4-alpine'
} ,
{
value : 'webdevops/php-apache:7.3-alpine' ,
label : 'webdevops/php-apache:7.3-alpine'
} ,
{
value : 'webdevops/php-nginx:7.3-alpine' ,
label : 'webdevops/php-nginx:7.3-alpine'
} ,
{
value : 'webdevops/php-apache:7.2-alpine' ,
label : 'webdevops/php-apache:7.2-alpine'
} ,
{
value : 'webdevops/php-nginx:7.2-alpine' ,
label : 'webdevops/php-nginx:7.2-alpine'
} ,
{
value : 'webdevops/php-apache:7.1-alpine' ,
label : 'webdevops/php-apache:7.1-alpine'
} ,
{
value : 'webdevops/php-nginx:7.1-alpine' ,
label : 'webdevops/php-nginx:7.1-alpine'
}
] ;
2022-05-10 09:10:58 +00:00
const pythonVersions = [
2022-05-10 12:26:25 +00:00
{
value : 'python:3.10-alpine' ,
label : 'python:3.10-alpine'
} ,
2022-05-10 09:10:58 +00:00
{
value : 'python:3.10-buster' ,
label : 'python:3.10-buster'
} ,
{
value : 'python:3.10-bullseye' ,
label : 'python:3.10-bullseye'
} ,
{
value : 'python:3.10-slim-bullseye' ,
label : 'python:3.10-slim-bullseye'
} ,
{
value : 'python:3.9-alpine' ,
label : 'python:3.9-alpine'
} ,
{
value : 'python:3.9-buster' ,
label : 'python:3.9-buster'
} ,
{
value : 'python:3.9-bullseye' ,
label : 'python:3.9-bullseye'
} ,
{
value : 'python:3.9-slim-bullseye' ,
label : 'python:3.9-slim-bullseye'
} ,
{
value : 'python:3.8-alpine' ,
label : 'python:3.8-alpine'
} ,
{
value : 'python:3.8-buster' ,
label : 'python:3.8-buster'
} ,
{
value : 'python:3.8-bullseye' ,
label : 'python:3.8-bullseye'
} ,
{
value : 'python:3.8-slim-bullseye' ,
label : 'python:3.8-slim-bullseye'
} ,
{
value : 'python:3.7-alpine' ,
label : 'python:3.7-alpine'
} ,
{
value : 'python:3.7-buster' ,
label : 'python:3.7-buster'
} ,
{
value : 'python:3.7-bullseye' ,
label : 'python:3.7-bullseye'
} ,
{
value : 'python:3.7-slim-bullseye' ,
label : 'python:3.7-slim-bullseye'
}
] ;
2022-08-16 11:58:37 +00:00
const herokuVersions = [
{
value : 'heroku/builder:22' ,
label : 'heroku/builder:22'
} ,
{
value : 'heroku/buildpacks:20' ,
label : 'heroku/buildpacks:20'
} ,
{
value : 'heroku/builder-classic:22' ,
label : 'heroku/builder-classic:22'
} ,
]
2022-07-06 09:02:36 +00:00
let payload : any = {
2022-04-26 12:51:08 +00:00
baseImage : null ,
baseBuildImage : null ,
baseImages : [ ] ,
baseBuildImages : [ ]
} ;
if ( nodeBased . includes ( buildPack ) ) {
2022-07-08 14:51:58 +00:00
if ( deploymentType === 'static' ) {
payload . baseImage = 'webdevops/nginx:alpine' ;
payload . baseImages = staticVersions ;
payload . baseBuildImage = 'node:lts' ;
payload . baseBuildImages = nodeVersions ;
} else {
payload . baseImage = 'node:lts' ;
payload . baseImages = nodeVersions ;
payload . baseBuildImage = 'node:lts' ;
payload . baseBuildImages = nodeVersions ;
}
2022-04-26 12:51:08 +00:00
}
if ( staticApps . includes ( buildPack ) ) {
payload . baseImage = 'webdevops/nginx:alpine' ;
payload . baseImages = staticVersions ;
payload . baseBuildImage = 'node:lts' ;
payload . baseBuildImages = nodeVersions ;
}
if ( buildPack === 'python' ) {
2022-05-10 12:26:25 +00:00
payload . baseImage = 'python:3.10-alpine' ;
2022-05-10 09:10:58 +00:00
payload . baseImages = pythonVersions ;
2022-04-26 12:51:08 +00:00
}
if ( buildPack === 'rust' ) {
payload . baseImage = 'rust:latest' ;
payload . baseBuildImage = 'rust:latest' ;
payload . baseImages = rustVersions ;
payload . baseBuildImages = rustVersions ;
}
if ( buildPack === 'deno' ) {
payload . baseImage = 'denoland/deno:latest' ;
}
if ( buildPack === 'php' ) {
payload . baseImage = 'webdevops/php-apache:8.0-alpine' ;
payload . baseImages = phpVersions ;
}
2022-04-28 13:10:45 +00:00
if ( buildPack === 'laravel' ) {
2022-04-29 20:24:14 +00:00
payload . baseImage = 'webdevops/php-apache:8.0-alpine' ;
2022-04-28 13:10:45 +00:00
payload . baseBuildImage = 'node:18' ;
payload . baseBuildImages = nodeVersions ;
}
2022-08-16 11:58:37 +00:00
if ( buildPack === 'heroku' ) {
payload . baseImage = 'heroku/buildpacks:20' ;
payload . baseImages = herokuVersions ;
}
2022-04-26 12:51:08 +00:00
return payload ;
}
2022-07-06 09:02:36 +00:00
export const setDefaultConfiguration = async ( data : any ) = > {
let {
buildPack ,
port ,
installCommand ,
startCommand ,
buildCommand ,
publishDirectory ,
baseDirectory ,
dockerFileLocation ,
denoMainFile
} = data ;
//@ts-ignore
const template = scanningTemplates [ buildPack ] ;
if ( ! port ) {
port = template ? . port || 3000 ;
if ( buildPack === 'static' ) port = 80 ;
else if ( buildPack === 'node' ) port = 3000 ;
else if ( buildPack === 'php' ) port = 80 ;
else if ( buildPack === 'python' ) port = 8000 ;
}
if ( ! installCommand && buildPack !== 'static' && buildPack !== 'laravel' )
installCommand = template ? . installCommand || 'yarn install' ;
if ( ! startCommand && buildPack !== 'static' && buildPack !== 'laravel' )
startCommand = template ? . startCommand || 'yarn start' ;
if ( ! buildCommand && buildPack !== 'static' && buildPack !== 'laravel' )
buildCommand = template ? . buildCommand || null ;
if ( ! publishDirectory ) publishDirectory = template ? . publishDirectory || null ;
if ( baseDirectory ) {
if ( ! baseDirectory . startsWith ( '/' ) ) baseDirectory = ` / ${ baseDirectory } ` ;
if ( ! baseDirectory . endsWith ( '/' ) ) baseDirectory = ` ${ baseDirectory } / ` ;
}
if ( dockerFileLocation ) {
if ( ! dockerFileLocation . startsWith ( '/' ) ) dockerFileLocation = ` / ${ dockerFileLocation } ` ;
if ( dockerFileLocation . endsWith ( '/' ) ) dockerFileLocation = dockerFileLocation . slice ( 0 , - 1 ) ;
} else {
dockerFileLocation = '/Dockerfile' ;
}
if ( ! denoMainFile ) {
denoMainFile = 'main.ts' ;
}
return {
buildPack ,
port ,
installCommand ,
startCommand ,
buildCommand ,
publishDirectory ,
baseDirectory ,
dockerFileLocation ,
denoMainFile
} ;
} ;
export const scanningTemplates = {
'@sveltejs/kit' : {
buildPack : 'nodejs'
} ,
astro : {
buildPack : 'astro'
} ,
'@11ty/eleventy' : {
buildPack : 'eleventy'
} ,
svelte : {
buildPack : 'svelte'
} ,
'@nestjs/core' : {
buildPack : 'nestjs'
} ,
next : {
buildPack : 'nextjs'
} ,
nuxt : {
buildPack : 'nuxtjs'
} ,
'react-scripts' : {
buildPack : 'react'
} ,
'parcel-bundler' : {
buildPack : 'static'
} ,
'@vue/cli-service' : {
buildPack : 'vuejs'
} ,
vuejs : {
buildPack : 'vuejs'
} ,
gatsby : {
buildPack : 'gatsby'
} ,
'preact-cli' : {
buildPack : 'react'
}
} ;
export const saveBuildLog = async ( {
line ,
buildId ,
applicationId
} : {
line : string ;
buildId : string ;
applicationId : string ;
} ) : Promise < any > = > {
if ( line && typeof line === 'string' && line . includes ( 'ghs_' ) ) {
const regex = /ghs_.*@/g ;
line = line . replace ( regex , '<SENSITIVE_DATA_DELETED>@' ) ;
}
const addTimestamp = ` [ ${ generateTimestamp ( ) } ] ${ line } ` ;
if ( isDev ) console . debug ( ` [ ${ applicationId } ] ${ addTimestamp } ` ) ;
return await prisma . buildLog . create ( {
data : {
line : addTimestamp , buildId , time : Number ( day ( ) . valueOf ( ) ) , applicationId
}
} ) ;
} ;
export async function copyBaseConfigurationFiles (
buildPack ,
workdir ,
buildId ,
applicationId ,
baseImage
) {
try {
if ( buildPack === 'php' ) {
await fs . writeFile ( ` ${ workdir } /entrypoint.sh ` , ` chown -R 1000 /app ` ) ;
await saveBuildLog ( {
line : 'Copied default configuration file for PHP.' ,
buildId ,
applicationId
} ) ;
2022-07-12 07:58:59 +00:00
} else if ( baseImage ? . includes ( 'nginx' ) ) {
2022-07-06 09:02:36 +00:00
await fs . writeFile (
` ${ workdir } /nginx.conf ` ,
` user nginx;
worker_processes auto ;
error_log / docker . stdout ;
pid / run / nginx . pid ;
events {
worker_connections 1024 ;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"' ;
access_log / docker . stdout main ;
sendfile on ;
tcp_nopush on ;
tcp_nodelay on ;
keepalive_timeout 65 ;
types_hash_max_size 2048 ;
include / etc / nginx / mime . types ;
default_type application / octet - stream ;
server {
listen 80 ;
server_name localhost ;
location / {
root / app ;
index index . html ;
try_files $uri $uri / index . html $uri / / i n d e x . h t m l = 4 0 4 ;
}
error_page 404 / 50 x . html ;
# redirect server error pages to the static page / 50 x . html
#
error_page 500 502 503 504 / 50 x . html ;
location = / 5 0 x . h t m l {
root / app ;
}
}
}
`
) ;
}
} catch ( error ) {
console . log ( error ) ;
throw new Error ( error ) ;
}
}
export function checkPnpm ( installCommand = null , buildCommand = null , startCommand = null ) {
return (
installCommand ? . includes ( 'pnpm' ) ||
buildCommand ? . includes ( 'pnpm' ) ||
startCommand ? . includes ( 'pnpm' )
) ;
}
export async function buildImage ( {
applicationId ,
tag ,
workdir ,
buildId ,
2022-07-21 12:43:53 +00:00
dockerId ,
2022-07-06 09:02:36 +00:00
isCache = false ,
debug = false ,
dockerFileLocation = '/Dockerfile'
} ) {
if ( isCache ) {
await saveBuildLog ( { line : ` Building cache image started. ` , buildId , applicationId } ) ;
} else {
await saveBuildLog ( { line : ` Building image started. ` , buildId , applicationId } ) ;
}
2022-07-21 12:43:53 +00:00
if ( debug ) {
2022-08-12 08:18:05 +00:00
await saveBuildLog ( { line : ` \ n############### \ nIMPORTANT: Due to some issues during implementing Remote Docker Engine, the builds logs are not streamed at the moment - but will be soon! You will see the full build log when the build is finished! \ n############### ` , buildId , applicationId } ) ;
2022-07-21 12:43:53 +00:00
}
2022-07-06 09:02:36 +00:00
if ( ! debug && isCache ) {
await saveBuildLog ( {
line : ` Debug turned off. To see more details, allow it in the configuration. ` ,
buildId ,
applicationId
} ) ;
}
2022-07-21 12:43:53 +00:00
const dockerFile = isCache ? ` ${ dockerFileLocation } -cache ` : ` ${ dockerFileLocation } `
const cache = ` ${ applicationId } : ${ tag } ${ isCache ? '-cache' : '' } `
const { stderr } = await executeDockerCmd ( { dockerId , command : ` docker build --progress plain -f ${ workdir } / ${ dockerFile } -t ${ cache } ${ workdir } ` } )
if ( debug ) {
const array = stderr . split ( '\n' )
for ( const line of array ) {
if ( line !== '\n' ) {
await saveBuildLog ( {
line : ` ${ line . replace ( '\n' , '' ) } ` ,
buildId ,
applicationId
} ) ;
}
2022-07-06 09:02:36 +00:00
}
2022-07-21 12:43:53 +00:00
}
// await new Promise((resolve, reject) => {
// const command = spawn(`docker`, ['build', '-f', `${workdir}${dockerFile}`, '-t', `${cache}`,`${workdir}`], {
// env: {
// DOCKER_HOST: 'ssh://root@95.217.178.202',
// DOCKER_BUILDKIT: '1'
// }
// });
// command.stdout.on('data', function (data) {
// console.log('stdout: ' + data);
// });
// command.stderr.on('data', function (data) {
// console.log('stderr: ' + data);
// });
// command.on('error', function (error) {
// console.log(error)
// reject(error)
// })
// command.on('exit', function (code) {
// console.log('exit code: ' + code);
// resolve(code)
// });
// })
// console.log({ stdout, stderr })
// const stream = await docker.engine.buildImage(
// { src: ['.'], context: workdir },
// {
// dockerfile: isCache ? `${dockerFileLocation}-cache` : dockerFileLocation,
// t: `${applicationId}:${tag}${isCache ? '-cache' : ''}`
// }
// );
// await streamEvents({ stream, docker, buildId, applicationId, debug });
2022-07-26 07:22:57 +00:00
if ( isCache ) {
await saveBuildLog ( { line : ` Building cache image successful. ` , buildId , applicationId } ) ;
} else {
await saveBuildLog ( { line : ` Building image successful. ` , buildId , applicationId } ) ;
}
2022-07-06 09:02:36 +00:00
}
export async function streamEvents ( { stream , docker , buildId , applicationId , debug } ) {
await new Promise ( ( resolve , reject ) = > {
docker . engine . modem . followProgress ( stream , onFinished , onProgress ) ;
function onFinished ( err , res ) {
if ( err ) reject ( err ) ;
resolve ( res ) ;
}
async function onProgress ( event ) {
if ( event . error ) {
reject ( event . error ) ;
} else if ( event . stream ) {
if ( event . stream !== '\n' ) {
if ( debug )
await saveBuildLog ( {
line : ` ${ event . stream . replace ( '\n' , '' ) } ` ,
buildId ,
applicationId
} ) ;
}
}
}
} ) ;
}
export function makeLabelForStandaloneApplication ( {
applicationId ,
fqdn ,
name ,
type ,
pullmergeRequestId = null ,
buildPack ,
repository ,
branch ,
projectId ,
port ,
commit ,
installCommand ,
buildCommand ,
startCommand ,
baseDirectory ,
publishDirectory
} ) {
if ( pullmergeRequestId ) {
const protocol = fqdn . startsWith ( 'https://' ) ? 'https' : 'http' ;
const domain = getDomain ( fqdn ) ;
fqdn = ` ${ protocol } :// ${ pullmergeRequestId } . ${ domain } ` ;
}
return [
'coolify.managed=true' ,
` coolify.version= ${ version } ` ,
` coolify.type=standalone-application ` ,
` coolify.configuration= ${ base64Encode (
JSON . stringify ( {
applicationId ,
fqdn ,
name ,
type ,
pullmergeRequestId ,
buildPack ,
repository ,
branch ,
projectId ,
port ,
commit ,
installCommand ,
buildCommand ,
startCommand ,
baseDirectory ,
publishDirectory
} )
) } `
] ;
}
export async function buildCacheImageWithNode ( data , imageForBuild ) {
const {
workdir ,
buildId ,
baseDirectory ,
installCommand ,
buildCommand ,
secrets ,
pullmergeRequestId
} = data ;
2022-07-21 12:43:53 +00:00
2022-07-06 09:02:36 +00:00
const isPnpm = checkPnpm ( installCommand , buildCommand ) ;
const Dockerfile : Array < string > = [ ] ;
Dockerfile . push ( ` FROM ${ imageForBuild } ` ) ;
Dockerfile . push ( 'WORKDIR /app' ) ;
Dockerfile . push ( ` LABEL coolify.buildId= ${ buildId } ` ) ;
if ( secrets . length > 0 ) {
secrets . forEach ( ( secret ) = > {
if ( secret . isBuildSecret ) {
if ( pullmergeRequestId ) {
if ( secret . isPRMRSecret ) {
Dockerfile . push ( ` ARG ${ secret . name } = ${ secret . value } ` ) ;
}
} else {
if ( ! secret . isPRMRSecret ) {
Dockerfile . push ( ` ARG ${ secret . name } = ${ secret . value } ` ) ;
}
}
}
} ) ;
}
if ( isPnpm ) {
Dockerfile . push ( 'RUN curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7' ) ;
}
if ( installCommand ) {
Dockerfile . push ( ` COPY . ${ baseDirectory || '' } /package.json ./ ` ) ;
Dockerfile . push ( ` RUN ${ installCommand } ` ) ;
}
Dockerfile . push ( ` COPY . ${ baseDirectory || '' } ./ ` ) ;
Dockerfile . push ( ` RUN ${ buildCommand } ` ) ;
await fs . writeFile ( ` ${ workdir } /Dockerfile-cache ` , Dockerfile . join ( '\n' ) ) ;
2022-07-26 07:22:57 +00:00
await buildImage ( { . . . data , isCache : true } ) ;
2022-07-06 09:02:36 +00:00
}
export async function buildCacheImageForLaravel ( data , imageForBuild ) {
2022-07-21 12:43:53 +00:00
const { workdir , buildId , secrets , pullmergeRequestId } = data ;
2022-07-06 09:02:36 +00:00
const Dockerfile : Array < string > = [ ] ;
Dockerfile . push ( ` FROM ${ imageForBuild } ` ) ;
Dockerfile . push ( 'WORKDIR /app' ) ;
Dockerfile . push ( ` LABEL coolify.buildId= ${ buildId } ` ) ;
if ( secrets . length > 0 ) {
secrets . forEach ( ( secret ) = > {
if ( secret . isBuildSecret ) {
if ( pullmergeRequestId ) {
if ( secret . isPRMRSecret ) {
Dockerfile . push ( ` ARG ${ secret . name } = ${ secret . value } ` ) ;
}
} else {
if ( ! secret . isPRMRSecret ) {
Dockerfile . push ( ` ARG ${ secret . name } = ${ secret . value } ` ) ;
}
}
}
} ) ;
}
Dockerfile . push ( ` COPY *.json *.mix.js /app/ ` ) ;
Dockerfile . push ( ` COPY resources /app/resources ` ) ;
Dockerfile . push ( ` RUN yarn install && yarn production ` ) ;
await fs . writeFile ( ` ${ workdir } /Dockerfile-cache ` , Dockerfile . join ( '\n' ) ) ;
2022-07-26 07:22:57 +00:00
await buildImage ( { . . . data , isCache : true } ) ;
2022-07-06 09:02:36 +00:00
}
export async function buildCacheImageWithCargo ( data , imageForBuild ) {
const {
applicationId ,
workdir ,
buildId ,
} = data ;
2022-07-21 12:43:53 +00:00
2022-07-06 09:02:36 +00:00
const Dockerfile : Array < string > = [ ] ;
Dockerfile . push ( ` FROM ${ imageForBuild } as planner- ${ applicationId } ` ) ;
Dockerfile . push ( ` LABEL coolify.buildId= ${ buildId } ` ) ;
Dockerfile . push ( 'WORKDIR /app' ) ;
Dockerfile . push ( 'RUN cargo install cargo-chef' ) ;
Dockerfile . push ( 'COPY . .' ) ;
Dockerfile . push ( 'RUN cargo chef prepare --recipe-path recipe.json' ) ;
Dockerfile . push ( ` FROM ${ imageForBuild } ` ) ;
Dockerfile . push ( ` LABEL coolify.buildId= ${ buildId } ` ) ;
Dockerfile . push ( 'WORKDIR /app' ) ;
Dockerfile . push ( 'RUN cargo install cargo-chef' ) ;
Dockerfile . push ( ` COPY --from=planner- ${ applicationId } /app/recipe.json recipe.json ` ) ;
Dockerfile . push ( 'RUN cargo chef cook --release --recipe-path recipe.json' ) ;
await fs . writeFile ( ` ${ workdir } /Dockerfile-cache ` , Dockerfile . join ( '\n' ) ) ;
2022-07-26 07:22:57 +00:00
await buildImage ( { . . . data , isCache : true } ) ;
2022-07-06 09:02:36 +00:00
}